better, and check against overflow

This commit is contained in:
Christian Grothoff
2009-11-16 13:40:10 +00:00
parent 735bf2d2aa
commit db0b0e4208
+3 -3
View File
@@ -493,12 +493,12 @@ MHD_handle_connection (void *data)
struct pollfd p;
timeout = con->daemon->connection_timeout;
if (timeout == 0)
timeout = -1; /* 'forever' */
while ((!con->daemon->shutdown) && (con->socket_fd != -1)) {
now = time (NULL);
tv.tv_usec = 0;
if (timeout > (now - con->last_activity))
if ( ( (timeout > (now - con->last_activity)) &&
(now > con->last_activity) ) ||
(timeout == 0) )
{
/* in case we are missing the SIGALRM, keep going after
at most 1s; see http://lists.gnu.org/archive/html/libmicrohttpd/2009-10/msg00013.html */