mirror of
https://repo.or.cz/socat.git
synced 2024-12-22 15:32:35 +00:00
replaced select() by poll() in comments
This commit is contained in:
parent
e142c3da6b
commit
1924e17cf0
6 changed files with 20 additions and 20 deletions
22
socat.c
22
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) {
|
||||
|
|
|
@ -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;*/
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue