diff options
author | Nick Mathewson <nickm@torproject.org> | 2004-05-05 01:01:34 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2004-05-05 01:01:34 +0000 |
commit | d49d3dcc7bc19e9b9fb2aa29f7d94379a8aedf52 (patch) | |
tree | 92abedc5551581dc6e80546216a78ce96f6ec312 /src/common/fakepoll.c | |
parent | 608c15682049ee375f81655625b9f85d6a600a1a (diff) | |
download | tor-d49d3dcc7bc19e9b9fb2aa29f7d94379a8aedf52.tar.gz tor-d49d3dcc7bc19e9b9fb2aa29f7d94379a8aedf52.zip |
Make non-fake tor_poll robust against -1 fds
svn:r1787
Diffstat (limited to 'src/common/fakepoll.c')
-rw-r--r-- | src/common/fakepoll.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/common/fakepoll.c b/src/common/fakepoll.c index 1fd380fd5c..bdc2831ea7 100644 --- a/src/common/fakepoll.c +++ b/src/common/fakepoll.c @@ -9,8 +9,9 @@ #include "orconfig.h" #include "fakepoll.h" -#ifdef USE_FAKE_POLL +#ifdef HAVE_SYS_TYPES_H #include <sys/types.h> +#endif #ifdef HAVE_UNISTD_H #include <unistd.h> #endif @@ -27,16 +28,27 @@ #include <winsock.h> #endif -/* by default, windows handles only 64 fd's */ -#if defined(MS_WINDOWS) && !defined(FD_SETSIZE) -#define FD_SETSIZE MAXCONNECTIONS -#endif - #include <assert.h> #include <stdlib.h> #include "util.h" #include "log.h" +#ifndef USE_FAKE_POLL +int +tor_poll(struct pollfd *ufds, unsigned int nfds, int timeout) +{ + int i; + for (i=0;i<nfds;++i) { + tor_assert(ufds[i].fd >= 0); + } + return poll(ufds,nfds,timeout); +} +#else +/* by default, windows handles only 64 fd's */ +#if defined(MS_WINDOWS) && !defined(FD_SETSIZE) +#define FD_SETSIZE MAXCONNECTIONS +#endif + int tor_poll(struct pollfd *ufds, unsigned int nfds, int timeout) { |