changeset 14046:483bac6e8bce

select tests: Improve comments. * tests/test-select.c (do_select): Add comments.
author Bruno Haible <bruno@clisp.org>
date Mon, 27 Dec 2010 18:53:31 +0100
parents eb1a951e4f56
children 126b2fb2abab
files ChangeLog tests/test-select.c
diffstat 2 files changed, 23 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-12-27  Bruno Haible  <bruno@clisp.org>
+
+	select tests: Improve comments.
+	* tests/test-select.c (do_select): Add comments.
+
 2010-12-27  Bruno Haible  <bruno@clisp.org>
 
 	select tests: Safer way of handling timeout.
--- a/tests/test-select.c
+++ b/tests/test-select.c
@@ -51,8 +51,6 @@
 
 #include "macros.h"
 
-enum { SEL_IN = 1, SEL_OUT = 2, SEL_EXC = 4 };
-
 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
 # define WIN32_NATIVE
 #endif
@@ -165,10 +163,20 @@
 }
 
 
-/* A slightly more convenient interface to select(2).  */
+/* A slightly more convenient interface to select(2).
+   Waits until a specific event occurs on a file descriptor FD.
+   EV is a bit mask of events to look for:
+     SEL_IN - input can be polled without blocking,
+     SEL_OUT - output can be provided without blocking,
+     SEL_EXC - an exception occurred,
+   A maximum wait time is specified by TIMEOUT.
+   *TIMEOUT = { 0, 0 } means to return immediately,
+   TIMEOUT = NULL means to wait indefinitely.  */
+
+enum { SEL_IN = 1, SEL_OUT = 2, SEL_EXC = 4 };
 
 static int
-do_select (int fd, int ev, struct timeval *tv)
+do_select (int fd, int ev, struct timeval *timeout)
 {
   fd_set rfds, wfds, xfds;
   int r, rev;
@@ -182,7 +190,7 @@
     FD_SET (fd, &wfds);
   if (ev & SEL_EXC)
     FD_SET (fd, &xfds);
-  r = select (fd + 1, &rfds, &wfds, &xfds, tv);
+  r = select (fd + 1, &rfds, &wfds, &xfds, timeout);
   if (r < 0)
     return r;
 
@@ -217,7 +225,7 @@
 }
 
 
-/* Test poll(2) for TTYs.  */
+/* Test select(2) for TTYs.  */
 
 #ifdef INTERACTIVE
 static void
@@ -238,7 +246,7 @@
 #endif
 
 
-/* Test poll(2) for unconnected nonblocking sockets.  */
+/* Test select(2) for unconnected nonblocking sockets.  */
 
 static void
 test_connect_first (void)
@@ -267,7 +275,7 @@
 }
 
 
-/* Test poll(2) for unconnected blocking sockets.  */
+/* Test select(2) for unconnected blocking sockets.  */
 
 static void
 test_accept_first (void)
@@ -333,7 +341,7 @@
 }
 
 
-/* Test poll(2) on connected sockets.  */
+/* Test select(2) on connected sockets.  */
 
 static void
 test_socket_pair (void)
@@ -354,7 +362,7 @@
 }
 
 
-/* Test poll(2) on pipes.  */
+/* Test select(2) on pipes.  */
 
 static void
 test_pipe (void)