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.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c
index f4273453..ee796fd8 100644
--- a/src/daemon/daemon.c
+++ b/src/daemon/daemon.c
@@ -1248,6 +1248,13 @@ MHD_get_timeout (struct MHD_Daemon *daemon,
1248 struct MHD_Connection *pos; 1248 struct MHD_Connection *pos;
1249 unsigned int dto; 1249 unsigned int dto;
1250 1250
1251 if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
1252 {
1253#if HAVE_MESSAGES
1254 MHD_DLOG (daemon, "Illegal call to MHD_get_timeout\n");
1255#endif
1256 return MHD_NO;
1257 }
1251 dto = daemon->connection_timeout; 1258 dto = daemon->connection_timeout;
1252 if (0 == dto) 1259 if (0 == dto)
1253 return MHD_NO; 1260 return MHD_NO;
@@ -1334,7 +1341,8 @@ MHD_select (struct MHD_Daemon *daemon,
1334 timeout.tv_sec = 0; 1341 timeout.tv_sec = 0;
1335 tv = &timeout; 1342 tv = &timeout;
1336 } 1343 }
1337 else if (MHD_YES == MHD_get_timeout (daemon, &ltimeout)) 1344 else if ( (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
1345 (MHD_YES == MHD_get_timeout (daemon, &ltimeout)) )
1338 { 1346 {
1339 /* ltimeout is in ms */ 1347 /* ltimeout is in ms */
1340 timeout.tv_usec = (ltimeout % 1000) * 1000; 1348 timeout.tv_usec = (ltimeout % 1000) * 1000;
@@ -1429,7 +1437,8 @@ MHD_poll_all (struct MHD_Daemon *daemon,
1429 } 1437 }
1430 if (may_block == MHD_NO) 1438 if (may_block == MHD_NO)
1431 timeout = 0; 1439 timeout = 0;
1432 else if (MHD_YES != MHD_get_timeout (daemon, &ltimeout)) 1440 else if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) ||
1441 (MHD_YES != MHD_get_timeout (daemon, &ltimeout)) )
1433 timeout = -1; 1442 timeout = -1;
1434 else 1443 else
1435 timeout = (ltimeout > INT_MAX) ? INT_MAX : (int) ltimeout; 1444 timeout = (ltimeout > INT_MAX) ? INT_MAX : (int) ltimeout;
@@ -1502,7 +1511,6 @@ MHD_poll_listen_socket (struct MHD_Daemon *daemon,
1502 int may_block) 1511 int may_block)
1503{ 1512{
1504 struct pollfd p; 1513 struct pollfd p;
1505 unsigned MHD_LONG_LONG ltimeout;
1506 int timeout; 1514 int timeout;
1507 1515
1508 memset (&p, 0, sizeof (p)); 1516 memset (&p, 0, sizeof (p));
@@ -1511,10 +1519,8 @@ MHD_poll_listen_socket (struct MHD_Daemon *daemon,
1511 p.revents = 0; 1519 p.revents = 0;
1512 if (may_block == MHD_NO) 1520 if (may_block == MHD_NO)
1513 timeout = 0; 1521 timeout = 0;
1514 else if (MHD_YES != MHD_get_timeout (daemon, &ltimeout))
1515 timeout = -1;
1516 else 1522 else
1517 timeout = (ltimeout > INT_MAX) ? INT_MAX : (int) ltimeout; 1523 timeout = -1;
1518#ifdef __CYGWIN__ 1524#ifdef __CYGWIN__
1519 /* See https://gnunet.org/bugs/view.php?id=1674 */ 1525 /* See https://gnunet.org/bugs/view.php?id=1674 */
1520 timeout = ( (timeout > 2000) || (timeout < 0) ) ? 2000 : timeout; 1526 timeout = ( (timeout > 2000) || (timeout < 0) ) ? 2000 : timeout;
@@ -1582,9 +1588,13 @@ MHD_run (struct MHD_Daemon *daemon)
1582 || (0 != (daemon->options & MHD_USE_SELECT_INTERNALLY))) 1588 || (0 != (daemon->options & MHD_USE_SELECT_INTERNALLY)))
1583 return MHD_NO; 1589 return MHD_NO;
1584 if ((daemon->options & MHD_USE_POLL) == 0) 1590 if ((daemon->options & MHD_USE_POLL) == 0)
1585 MHD_select (daemon, MHD_NO); 1591 {
1592 MHD_select (daemon, MHD_NO);
1593 }
1586 else 1594 else
1587 MHD_poll (daemon, MHD_NO); 1595 {
1596 MHD_poll (daemon, MHD_NO);
1597 }
1588 MHD_cleanup_connections (daemon); 1598 MHD_cleanup_connections (daemon);
1589 return MHD_YES; 1599 return MHD_YES;
1590} 1600}