From 1924e17cf0ee19ff68ad66b0e179143aed1097fc Mon Sep 17 00:00:00 2001 From: Gerhard Rieger Date: Thu, 4 Sep 2008 23:42:52 +0200 Subject: [PATCH] replaced select() by poll() in comments --- socat.c | 22 +++++++++++----------- xio-socket.c | 2 +- xio-udp.c | 2 +- xioopts.c | 2 +- xioread.c | 4 ++-- xiowrite.c | 8 ++++---- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/socat.c b/socat.c index 78eda0c..f4cf771 100644 --- a/socat.c +++ b/socat.c @@ -684,10 +684,10 @@ int childleftdata(xiofile_t *xfd) { int xiotransfer(xiofile_t *inpipe, xiofile_t *outpipe, unsigned char **buff, size_t bufsiz, bool righttoleft); -bool mayrd1; /* sock1 has read data or eof, according to select() */ -bool mayrd2; /* sock2 has read data or eof, according to select() */ -bool maywr1; /* sock1 can be written to, according to select() */ -bool maywr2; /* sock2 can be written to, according to select() */ +bool mayrd1; /* sock1 has read data or eof, according to poll() */ +bool mayrd2; /* sock2 has read data or eof, according to poll() */ +bool maywr1; /* sock1 can be written to, according to poll() */ +bool maywr2; /* sock2 can be written to, according to poll() */ /* here we come when the sockets are opened (in the meaning of C language), and their options are set/applied @@ -702,7 +702,7 @@ int _socat(void) { unsigned char *buff; ssize_t bytes1, bytes2; int polling = 0; /* handling ignoreeof */ - int wasaction = 1; /* last select was active, do NOT sleep before next */ + int wasaction = 1; /* last poll was active, do NOT sleep before next */ struct timeval total_timeout; /* the actual total timeout timer */ #if WITH_FILAN @@ -760,7 +760,7 @@ int _socat(void) { /* for ignoreeof */ if (polling) { if (!wasaction) { - /* yes we could do it with select but I like readable trace output */ + /* yes we could do it with poll but I like readable trace output */ if (socat_opts.pollintv.tv_sec) Sleep(socat_opts.pollintv.tv_sec); if (socat_opts.pollintv.tv_usec) Usleep(socat_opts.pollintv.tv_usec); @@ -804,7 +804,7 @@ int _socat(void) { closing = 2; } - do { + do { /* loop over poll() EINTR */ int _errno; childleftdata(sock1); @@ -859,7 +859,7 @@ int _socat(void) { retval = xiopoll(fds, 4, timeout); _errno = errno; if (retval < 0 && errno == EINTR) { - Info1("select(): %s", strerror(errno)); + Info1("poll(): %s", strerror(errno)); } errno = _errno; } while (retval < 0 && errno == EINTR); @@ -876,7 +876,7 @@ int _socat(void) { timeout, strerror(errno)); return -1; } else if (retval == 0) { - Info2("select timed out (no data within %ld.%06ld seconds)", + Info2("poll timed out (no data within %ld.%06ld seconds)", closing>=1?socat_opts.closwait.tv_sec:socat_opts.total_timeout.tv_sec, closing>=1?socat_opts.closwait.tv_usec:socat_opts.total_timeout.tv_usec); if (polling && !wasaction) { @@ -927,7 +927,7 @@ int _socat(void) { maywr2 = false; total_timeout = socat_opts.total_timeout; wasaction = 1; - /* is more data available that has already passed select()? */ + /* is more data available that has already passed poll()? */ mayrd1 = (xiopending(sock1) > 0); if (XIO_RDSTREAM(sock1)->readbytes != 0 && XIO_RDSTREAM(sock1)->actbytes == 0) { @@ -955,7 +955,7 @@ int _socat(void) { maywr1 = false; total_timeout = socat_opts.total_timeout; wasaction = 1; - /* is more data available that has already passed select()? */ + /* is more data available that has already passed poll()? */ mayrd2 = (xiopending(sock2) > 0); if (XIO_RDSTREAM(sock2)->readbytes != 0 && XIO_RDSTREAM(sock2)->actbytes == 0) { diff --git a/xio-socket.c b/xio-socket.c index bca7746..cd11c14 100644 --- a/xio-socket.c +++ b/xio-socket.c @@ -726,7 +726,7 @@ int _xioopen_dgram_recvfrom(struct single *xfd, int xioflags, drop = true; } - /* loop until select() returns valid */ + /* loop until select()/poll() returns valid */ do { struct pollfd readfd; /*? int level = E_ERROR;*/ diff --git a/xio-udp.c b/xio-udp.c index 64cf04a..293b8be 100644 --- a/xio-udp.c +++ b/xio-udp.c @@ -251,7 +251,7 @@ int xioopen_ipdgram_listen(int argc, const char *argv[], struct opt *opts, } break; } - /* server: continue loop with select */ + /* server: continue loop with socket()+recvfrom() */ /* when we dont close this we get awkward behaviour on Linux 2.4: recvfrom gives 0 bytes with invalid socket address */ if (Close(fd->stream.fd) < 0) { diff --git a/xioopts.c b/xioopts.c index 0652073..ad76434 100644 --- a/xioopts.c +++ b/xioopts.c @@ -3446,7 +3446,7 @@ int applyopts_single(struct single *xfd, struct opt *opts, enum e_phase phase) { xfd->lock.intervall.tv_sec = 1; xfd->lock.intervall.tv_nsec = 0; - /*! this should be integrated into central select loop */ + /*! this should be integrated into central select()/poll() loop */ if (xiolock(&xfd->lock) < 0) { return -1; } diff --git a/xioread.c b/xioread.c index 141d7fe..5db886c 100644 --- a/xioread.c +++ b/xioread.c @@ -366,8 +366,8 @@ ssize_t xioread(xiofile_t *file, void *buff, size_t bufsiz) { /* this function is intended only for some special address types where the - select() call cannot strictly determine if (more) read data is available. - currently this is for the OpenSSL based addresses. + select()/poll() calls cannot strictly determine if (more) read data is + available. currently this is for the OpenSSL based addresses. */ ssize_t xiopending(xiofile_t *file) { struct single *pipe; diff --git a/xiowrite.c b/xiowrite.c index 88c01e1..d02e48b 100644 --- a/xiowrite.c +++ b/xiowrite.c @@ -1,5 +1,5 @@ /* source: xiowrite.c */ -/* Copyright Gerhard Rieger 2001-2007 */ +/* Copyright Gerhard Rieger 2001-2008 */ /* Published under the GNU General Public License V.2, see file COPYING */ /* this is the source of the extended write function */ @@ -13,9 +13,9 @@ /* ... - note that the write() call can block even if the select() call reported the - FD writeable: in case the FD is not nonblocking and a lock defers the - operation. + note that the write() call can block even if the select()/poll() call + reported the FD writeable: in case the FD is not nonblocking and a lock + defers the operation. on return value < 0: errno reflects the value from write() */ ssize_t xiowrite(xiofile_t *file, const void *buff, size_t bytes) { ssize_t writt;