about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--Src/Modules/tcp.c27
2 files changed, 31 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 3a543222e..9a2b1081d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2001-09-27  Clint Adams  <clint@zsh.org>
+
+	* 15886: Src/Modules/tcp.c: use select if poll
+	is not available, or complain if neither are
+	available.
+
 2001-09-27  Peter Stephenson  <pws@csr.com>
 
 	* Config/version.mk, Completion/Unix/Command/.distfiles,
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
     {