diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-08-05 20:41:23 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-08-05 20:41:23 +0000 |
commit | 09666c65f649d07624fcbc832b8b7da9f5524c94 (patch) | |
tree | 21d961474d53a177558ceb3319083a463859f66c | |
parent | bdf374b29a1fd2961d0050a259d3f1018070b5f7 (diff) | |
download | libmicrohttpd-09666c65f649d07624fcbc832b8b7da9f5524c94.tar.gz libmicrohttpd-09666c65f649d07624fcbc832b8b7da9f5524c94.zip |
fixing time underflow bug
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | src/daemon/connection.c | 4 | ||||
-rw-r--r-- | src/daemon/daemon.c | 6 |
3 files changed, 7 insertions, 7 deletions
@@ -1,3 +1,7 @@ | |||
1 | Thu Aug 5 22:24:37 CEST 2010 | ||
2 | Fixing timeout bug on systems that think it's still | ||
3 | 1970 (can happen if system time not initialized). -CG | ||
4 | |||
1 | Mon Jul 26 10:46:57 CEST 2010 | 5 | Mon Jul 26 10:46:57 CEST 2010 |
2 | Releasing libmicrohttpd 0.9.0. -CG | 6 | Releasing libmicrohttpd 0.9.0. -CG |
3 | 7 | ||
diff --git a/src/daemon/connection.c b/src/daemon/connection.c index a56106a4..390bc461 100644 --- a/src/daemon/connection.c +++ b/src/daemon/connection.c | |||
@@ -2223,13 +2223,13 @@ MHD_connection_handle_idle (struct MHD_Connection *connection) | |||
2223 | } | 2223 | } |
2224 | timeout = connection->daemon->connection_timeout; | 2224 | timeout = connection->daemon->connection_timeout; |
2225 | if ((connection->socket_fd != -1) && | 2225 | if ((connection->socket_fd != -1) && |
2226 | (timeout != 0) && (time (NULL) - timeout > connection->last_activity)) | 2226 | (timeout != 0) && |
2227 | (timeout > (time (NULL) - con->last_activity)) ) | ||
2227 | { | 2228 | { |
2228 | MHD_connection_close (connection, MHD_REQUEST_TERMINATED_TIMEOUT_REACHED); | 2229 | MHD_connection_close (connection, MHD_REQUEST_TERMINATED_TIMEOUT_REACHED); |
2229 | return MHD_NO; | 2230 | return MHD_NO; |
2230 | } | 2231 | } |
2231 | return MHD_YES; | 2232 | return MHD_YES; |
2232 | |||
2233 | } | 2233 | } |
2234 | 2234 | ||
2235 | void | 2235 | void |
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c index 73a0f163..b23c6a70 100644 --- a/src/daemon/daemon.c +++ b/src/daemon/daemon.c | |||
@@ -486,7 +486,6 @@ MHD_handle_connection (void *data) | |||
486 | int max; | 486 | int max; |
487 | struct timeval tv; | 487 | struct timeval tv; |
488 | unsigned int timeout; | 488 | unsigned int timeout; |
489 | time_t now; | ||
490 | #ifdef HAVE_POLL_H | 489 | #ifdef HAVE_POLL_H |
491 | struct MHD_Pollfd mp; | 490 | struct MHD_Pollfd mp; |
492 | struct pollfd p; | 491 | struct pollfd p; |
@@ -494,9 +493,8 @@ MHD_handle_connection (void *data) | |||
494 | 493 | ||
495 | timeout = con->daemon->connection_timeout; | 494 | timeout = con->daemon->connection_timeout; |
496 | while ((!con->daemon->shutdown) && (con->socket_fd != -1)) { | 495 | while ((!con->daemon->shutdown) && (con->socket_fd != -1)) { |
497 | now = time (NULL); | ||
498 | tv.tv_usec = 0; | 496 | tv.tv_usec = 0; |
499 | if ( (timeout > (now - con->last_activity)) || | 497 | if ( (timeout > (time (NULL) - con->last_activity)) || |
500 | (timeout == 0) ) | 498 | (timeout == 0) ) |
501 | { | 499 | { |
502 | /* in case we are missing the SIGALRM, keep going after | 500 | /* in case we are missing the SIGALRM, keep going after |
@@ -1017,7 +1015,6 @@ MHD_select (struct MHD_Daemon *daemon, int may_block) | |||
1017 | struct timeval timeout; | 1015 | struct timeval timeout; |
1018 | unsigned long long ltimeout; | 1016 | unsigned long long ltimeout; |
1019 | int ds; | 1017 | int ds; |
1020 | time_t now; | ||
1021 | 1018 | ||
1022 | timeout.tv_sec = 0; | 1019 | timeout.tv_sec = 0; |
1023 | timeout.tv_usec = 0; | 1020 | timeout.tv_usec = 0; |
@@ -1090,7 +1087,6 @@ MHD_select (struct MHD_Daemon *daemon, int may_block) | |||
1090 | if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) | 1087 | if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) |
1091 | { | 1088 | { |
1092 | /* do not have a thread per connection, process all connections now */ | 1089 | /* do not have a thread per connection, process all connections now */ |
1093 | now = time (NULL); | ||
1094 | pos = daemon->connections; | 1090 | pos = daemon->connections; |
1095 | while (pos != NULL) | 1091 | while (pos != NULL) |
1096 | { | 1092 | { |