libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 09666c65f649d07624fcbc832b8b7da9f5524c94
parent bdf374b29a1fd2961d0050a259d3f1018070b5f7
Author: Christian Grothoff <christian@grothoff.org>
Date:   Thu,  5 Aug 2010 20:41:23 +0000

fixing time underflow bug

Diffstat:
MChangeLog | 4++++
Msrc/daemon/connection.c | 4++--
Msrc/daemon/daemon.c | 6+-----
3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,7 @@ +Thu Aug 5 22:24:37 CEST 2010 + Fixing timeout bug on systems that think it's still + 1970 (can happen if system time not initialized). -CG + Mon Jul 26 10:46:57 CEST 2010 Releasing libmicrohttpd 0.9.0. -CG diff --git a/src/daemon/connection.c b/src/daemon/connection.c @@ -2223,13 +2223,13 @@ MHD_connection_handle_idle (struct MHD_Connection *connection) } timeout = connection->daemon->connection_timeout; if ((connection->socket_fd != -1) && - (timeout != 0) && (time (NULL) - timeout > connection->last_activity)) + (timeout != 0) && + (timeout > (time (NULL) - con->last_activity)) ) { MHD_connection_close (connection, MHD_REQUEST_TERMINATED_TIMEOUT_REACHED); return MHD_NO; } return MHD_YES; - } void diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c @@ -486,7 +486,6 @@ MHD_handle_connection (void *data) int max; struct timeval tv; unsigned int timeout; - time_t now; #ifdef HAVE_POLL_H struct MHD_Pollfd mp; struct pollfd p; @@ -494,9 +493,8 @@ MHD_handle_connection (void *data) timeout = con->daemon->connection_timeout; while ((!con->daemon->shutdown) && (con->socket_fd != -1)) { - now = time (NULL); tv.tv_usec = 0; - if ( (timeout > (now - con->last_activity)) || + if ( (timeout > (time (NULL) - con->last_activity)) || (timeout == 0) ) { /* in case we are missing the SIGALRM, keep going after @@ -1017,7 +1015,6 @@ MHD_select (struct MHD_Daemon *daemon, int may_block) struct timeval timeout; unsigned long long ltimeout; int ds; - time_t now; timeout.tv_sec = 0; timeout.tv_usec = 0; @@ -1090,7 +1087,6 @@ MHD_select (struct MHD_Daemon *daemon, int may_block) if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) { /* do not have a thread per connection, process all connections now */ - now = time (NULL); pos = daemon->connections; while (pos != NULL) {