# HG changeset patch # User terom # Date 1229913388 0 # Node ID 6d387796b139d283ef12324dcdf3f479cf956d48 # Parent 2a57f0a871b020b127e92aca59c45e1d8dd6fb4f fix select EINTR issues diff -r 2a57f0a871b0 -r 6d387796b139 src/Network/Reactor.cc --- a/src/Network/Reactor.cc Wed Dec 17 01:13:26 2008 +0000 +++ b/src/Network/Reactor.cc Mon Dec 22 02:36:28 2008 +0000 @@ -1,7 +1,6 @@ #include "Reactor.hh" - NetworkReactor::NetworkReactor (void) : sockets() { @@ -9,6 +8,8 @@ } void NetworkReactor::poll (timeval *timeout) { + int ret; + // start counting the maximum fd from -1, so that select is given nfds=0 if our list is empty int fd_max = 0; @@ -47,18 +48,20 @@ } } - // run select - int ret; - - // we never care about except - // pass NULL fdsets if they are empty - if ((ret = select( + // loop select() on EINTR + do { + // we never care about except, and pass NULL fdsets if they are empty + ret = select( fd_max + 1, fd_max ? &read : NULL, fd_max ? &write : NULL, NULL, timeout - )) < 0) + ); + } while (ret < 0 && errno == EINTR); + + // error? + if (ret < 0) throw NetworkReactorError("select"); // ignore if we just timed out