aboutsummaryrefslogtreecommitdiff
path: root/src/daemon/daemon.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon/daemon.c')
-rw-r--r--src/daemon/daemon.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c
index ced8a64c..c23a4327 100644
--- a/src/daemon/daemon.c
+++ b/src/daemon/daemon.c
@@ -953,6 +953,7 @@ MHD_add_connection (struct MHD_Daemon *daemon,
953 return MHD_NO; 953 return MHD_NO;
954 } 954 }
955 memset (connection, 0, sizeof (struct MHD_Connection)); 955 memset (connection, 0, sizeof (struct MHD_Connection));
956 connection->connection_timeout = daemon->connection_timeout;
956 connection->pool = NULL; 957 connection->pool = NULL;
957 connection->addr = malloc (addrlen); 958 connection->addr = malloc (addrlen);
958 if (connection->addr == NULL) 959 if (connection->addr == NULL)
@@ -1222,7 +1223,6 @@ MHD_get_timeout (struct MHD_Daemon *daemon,
1222 time_t earliest_deadline; 1223 time_t earliest_deadline;
1223 time_t now; 1224 time_t now;
1224 struct MHD_Connection *pos; 1225 struct MHD_Connection *pos;
1225 unsigned int dto;
1226 1226
1227 if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) 1227 if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
1228 { 1228 {
@@ -1231,26 +1231,23 @@ MHD_get_timeout (struct MHD_Daemon *daemon,
1231#endif 1231#endif
1232 return MHD_NO; 1232 return MHD_NO;
1233 } 1233 }
1234 dto = daemon->connection_timeout;
1235 if (0 == dto)
1236 return MHD_NO;
1237 pos = daemon->connections_head; 1234 pos = daemon->connections_head;
1238 if (pos == NULL) 1235 if (pos == NULL)
1239 return MHD_NO; /* no connections */ 1236 return MHD_NO; /* no connections */
1240 now = time (NULL); 1237 earliest_deadline = pos->last_activity + pos->connection_timeout;
1241 /* start with conservative estimate */ 1238 pos = pos->next;
1242 earliest_deadline = now + dto + 1;
1243 while (pos != NULL) 1239 while (pos != NULL)
1244 { 1240 {
1245 if (earliest_deadline > pos->last_activity + dto) 1241 if (earliest_deadline > pos->last_activity + pos->connection_timeout)
1246 earliest_deadline = pos->last_activity + dto; 1242 earliest_deadline = pos->last_activity + pos->connection_timeout;
1247#if HTTPS_SUPPORT 1243#if HTTPS_SUPPORT
1248 if ( (0 != (daemon->options & MHD_USE_SSL)) && 1244 if ( (0 != (daemon->options & MHD_USE_SSL)) &&
1249 (0 != gnutls_record_check_pending (pos->tls_session)) ) 1245 (0 != gnutls_record_check_pending (pos->tls_session)) )
1250 earliest_deadline = now; 1246 earliest_deadline = 0;
1251#endif 1247#endif
1252 pos = pos->next; 1248 pos = pos->next;
1253 } 1249 }
1250 now = time (NULL);
1254 if (earliest_deadline < now) 1251 if (earliest_deadline < now)
1255 *timeout = 0; 1252 *timeout = 0;
1256 else 1253 else