Commit 0f9d30d5 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Use poll() instead of select() to fix an unlikely overflow in FD_SET

parent 61630d2b
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#include <poll.h>
#include "x11_timer.hpp" #include "x11_timer.hpp"
#include "x11_factory.hpp" #include "x11_factory.hpp"
...@@ -146,20 +147,14 @@ void X11TimerLoop::waitNextTimer() ...@@ -146,20 +147,14 @@ void X11TimerLoop::waitNextTimer()
bool X11TimerLoop::sleep( int delay ) bool X11TimerLoop::sleep( int delay )
{ {
// Timeout delay struct pollfd ufd = {
struct timeval tv; .fd = m_connectionNumber,
tv.tv_sec = delay / 1000; .events = POLLIN,
tv.tv_usec = 1000 * (delay % 1000); };
// FD set for select()
fd_set rfds;
FD_ZERO( &rfds );
FD_SET( m_connectionNumber, &rfds );
// Wait for an X11 event, or timeout // Wait for an X11 event, or timeout
int num = select( m_connectionNumber + 1, &rfds, NULL, NULL, &tv ); // TODO: use VLC object waitpipe?
return poll( &ufd, 1, delay ) > 0;
return ( num > 0 );
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment