]> git.pond.sub.org Git - empserver/commitdiff
Fix pthread's empth_select() not to change the timeout
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 1 Feb 2009 17:06:09 +0000 (18:06 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 1 Feb 2009 17:06:09 +0000 (18:06 +0100)
Commit 08b94556 introduced the timeout parameter.  The empthread
implementation could change it, at least on some systems, and its user
worked around a possible change.  However, that behavior was not
documented, and it's inconvenient.  Fix the pthread implementation,
and remove the workaround.

src/lib/empthread/io.c
src/lib/empthread/pthread.c

index 85cad537d714fbf61bc335dc96ec0f5169e2a73d..5d4d06c46f8b69e571453f7d8e292f2e24dc9e0d 100644 (file)
@@ -121,7 +121,6 @@ io_input(struct iop *iop, int waitforinput)
     char buf[IO_BUFSIZE];
     int cc;
     int res;
     char buf[IO_BUFSIZE];
     int cc;
     int res;
-    struct timeval timeout = iop->input_timeout;
 
     /* Not a read IOP */
     if ((iop->flags & IO_READ) == 0) {
 
     /* Not a read IOP */
     if ((iop->flags & IO_READ) == 0) {
@@ -135,7 +134,7 @@ io_input(struct iop *iop, int waitforinput)
     }
     /* Wait for the file to have input. */
     if (waitforinput) {
     }
     /* Wait for the file to have input. */
     if (waitforinput) {
-       res = empth_select(iop->fd, EMPTH_FD_READ, &timeout);
+       res = empth_select(iop->fd, EMPTH_FD_READ, &iop->input_timeout);
        if (res < 0) {
            iop->flags |= IO_ERROR;
            return -1;
        if (res < 0) {
            iop->flags |= IO_ERROR;
            return -1;
index 57a887ff891e914f158ab3a3b846ab1a4af88863..0f421ce952f3c1339f65348d6a86018f67668e07 100644 (file)
@@ -290,10 +290,11 @@ empth_terminate(empth_t *a)
 }
 
 int
 }
 
 int
-empth_select(int fd, int flags, struct timeval *tv)
+empth_select(int fd, int flags, struct timeval *timeout)
 {
     fd_set readmask;
     fd_set writemask;
 {
     fd_set readmask;
     fd_set writemask;
+    struct timeval tv;
     int n;
     int res = 0;
 
     int n;
     int res = 0;
 
@@ -318,7 +319,11 @@ empth_select(int fd, int flags, struct timeval *tv)
        goto done;
     }
 
        goto done;
     }
 
-    n = select(fd + 1, &readmask, &writemask, (fd_set *) 0, tv);
+    if (timeout) {
+       tv = *timeout;
+       timeout = &tv;
+    }
+    n = select(fd + 1, &readmask, &writemask, NULL, timeout);
 
     if (n < 0) {
        if (errno == EINTR) /* go handle the signal */
 
     if (n < 0) {
        if (errno == EINTR) /* go handle the signal */