Commits

gustafn committed 332e6ae

Simplify timeout logic for poll: the pre-existing logic could lead to negative timeouts other than -1 on the poll system call, which leads to an error (at least under mac os x 10.7.3). Since the timeout was used as a constant, make the timeout behavior explicit and set the poll timeout to -1 when intended.

Comments (0)

Files changed (1)

         if (readPtr == NULL) {
             pollto = 30 * 1000;
         } else {
-	    timeout.sec = TIME_T_MAX;
-            timeout.usec = 0;
             sockPtr = readPtr;
             while (sockPtr != NULL) {
                 SockPoll(sockPtr, POLLIN, &pdata);
                 sockPtr = sockPtr->nextPtr;
             }
-            if (Ns_DiffTime(&timeout, &now, &diff) > 0)  {
-                pollto = diff.sec * 1000 + diff.usec / 1000;
-            } else {
-                pollto = 0;
-            }
+	    pollto = -1;
         }
 
         /*
         if (writePtr == NULL) {
             pollto = 30 * 1000;
         } else {
-	    timeout.sec = TIME_T_MAX;
-            timeout.usec = 0;
             curPtr = writePtr;
             while (curPtr != NULL) {
                 if (curPtr->size > 0) {
                 }
                 curPtr = curPtr->nextPtr;
             }
-            if (Ns_DiffTime(&timeout, &now, &diff) > 0)  {
-                pollto = diff.sec * 1000 + diff.usec / 1000;
-            } else {
-                pollto = 0;
-            }
+	    pollto = -1;
         }
 
         /*
          * Select and drain the trigger pipe if necessary.
          */
-
         n = PollWait(&pdata, pollto);
 
         if (PollIn(&pdata, 0) && recv(queuePtr->pipe[0], &c, 1, 0) != 1) {