From 8c05772007d403450624056cd24f8d53efa2da70 Mon Sep 17 00:00:00 2001 From: Clint Adams Date: Thu, 27 Sep 2001 15:36:41 +0000 Subject: 15886: use select if poll is not available, or complain if neither are available --- Src/Modules/tcp.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'Src/Modules') diff --git a/Src/Modules/tcp.c b/Src/Modules/tcp.c index cde2c2374..ae1b21912 100644 --- a/Src/Modules/tcp.c +++ b/Src/Modules/tcp.c @@ -538,6 +538,8 @@ bin_ztcp(char *nam, char **args, char *ops, int func) } if(test) { +#if defined(HAVE_POLL) || defined(HAVE_SELECT) +# ifdef HAVE_POLL struct pollfd pfd; int ret; @@ -549,7 +551,29 @@ bin_ztcp(char *nam, char **args, char *ops, int func) zwarnnam(nam, "poll error: %e", NULL, errno); return 1; } - +# else + fd_set rfds; + struct timeval tv; + int ret; + + FD_ZERO(&rfds); + FD_SET(lfd, &rfds); + tv.tv_sec = 0; + tv.tv_usec = 0; + + if(ret = select(lfd+1, &rfds, NULL, NULL, &tv)) return 1; + else if (ret == -1) + { + zwarnnam(nam, "select error: %e", NULL, errno); + return 1; + } + +# endif + +#else + zwarnnam(nam, "not currently supported", NULL, 0); + return 1; +#endif } sess = zts_alloc(ZTCP_INBOUND); @@ -572,7 +596,6 @@ bin_ztcp(char *nam, char **args, char *ops, int func) if(verbose) fprintf(shout, "%d is on fd %d\n", ntohs(sess->peer.in.sin_port), sess->fd); - } else { -- cgit 1.4.1