From d49d3dcc7bc19e9b9fb2aa29f7d94379a8aedf52 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 5 May 2004 01:01:34 +0000 Subject: [PATCH] Make non-fake tor_poll robust against -1 fds svn:r1787 --- src/common/fakepoll.c | 24 ++++++++++++++++++------ src/common/fakepoll.h | 9 ++------- 2 files changed, 20 insertions(+), 13 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 +#endif #ifdef HAVE_UNISTD_H #include #endif @@ -27,16 +28,27 @@ #include #endif -/* by default, windows handles only 64 fd's */ -#if defined(MS_WINDOWS) && !defined(FD_SETSIZE) -#define FD_SETSIZE MAXCONNECTIONS -#endif - #include #include #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= 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) { diff --git a/src/common/fakepoll.h b/src/common/fakepoll.h index 4d0d9ce524..783aff0c42 100644 --- a/src/common/fakepoll.h +++ b/src/common/fakepoll.h @@ -19,15 +19,11 @@ * select. On Mac OS 10.3, this wrapper is kinda flaky, and we should * use our own. */ -#if (defined(HAVE_POLL_H)||defined(HAVE_SYS_POLL_H)) && !defined(_POLL_EMUL_H_) -#define tor_poll poll -#else +#if !(defined(HAVE_POLL_H)||defined(HAVE_SYS_POLL_H))&&!defined(_POLL_EMUL_H_) #define USE_FAKE_POLL #endif -#ifdef USE_FAKE_POLL - -#ifndef _POLL_EMUL_H_ +#if defined USE_FAKE_POLL && !defined(_POLL_EMUL_H_) struct pollfd { int fd; short events; @@ -43,7 +39,6 @@ struct pollfd { #endif int tor_poll(struct pollfd *ufds, unsigned int nfds, int timeout); -#endif #endif -- 2.11.4.GIT