aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/daemon.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/microhttpd/daemon.c')
-rw-r--r--src/microhttpd/daemon.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 3e7131c1..6ac948d9 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -4507,7 +4507,6 @@ MHD_select (struct MHD_Daemon *daemon,
4507 4507
4508 if (MHD_NO != err_state) 4508 if (MHD_NO != err_state)
4509 millisec = 0; 4509 millisec = 0;
4510 tv = NULL;
4511 if (0 == millisec) 4510 if (0 == millisec)
4512 { 4511 {
4513 timeout.tv_usec = 0; 4512 timeout.tv_usec = 0;
@@ -4516,32 +4515,40 @@ MHD_select (struct MHD_Daemon *daemon,
4516 } 4515 }
4517 else 4516 else
4518 { 4517 {
4519 uint64_t timeout64; 4518 uint64_t mhd_tmo;
4519 uint64_t select_tmo;
4520 4520
4521 if ( (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && 4521 if ( (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
4522 (MHD_NO != MHD_get_timeout64 (daemon, &timeout64)) ) 4522 (MHD_NO != MHD_get_timeout64 (daemon, &mhd_tmo)) )
4523 { 4523 {
4524 tv = &timeout; /* have timeout value */
4525 if ( (0 < millisec) && 4524 if ( (0 < millisec) &&
4526 (timeout64 > (uint64_t) millisec) ) 4525 (mhd_tmo > (uint64_t) millisec) )
4527 timeout64 = (uint64_t) millisec; 4526 select_tmo = (uint64_t) millisec;
4527 else
4528 select_tmo = mhd_tmo;
4529 tv = &timeout; /* have timeout value */
4528 } 4530 }
4529 else if (0 < millisec) 4531 else if (0 < millisec)
4530 { 4532 {
4533 select_tmo = (uint64_t) millisec;
4531 tv = &timeout; /* have timeout value */ 4534 tv = &timeout; /* have timeout value */
4532 timeout64 = (uint64_t) millisec; 4535 }
4536 else
4537 {
4538 select_tmo = 0; /* Not actually used, silent compiler warning */
4539 tv = NULL;
4533 } 4540 }
4534 4541
4535 if (NULL != tv) 4542 if (NULL != tv)
4536 { /* have timeout value */ 4543 { /* have timeout value */
4537#if (SIZEOF_UINT64_T - 2) >= SIZEOF_STRUCT_TIMEVAL_TV_SEC 4544#if (SIZEOF_UINT64_T - 2) >= SIZEOF_STRUCT_TIMEVAL_TV_SEC
4538 if (timeout64 / 1000 > TIMEVAL_TV_SEC_MAX) 4545 if (select_tmo / 1000 > TIMEVAL_TV_SEC_MAX)
4539 timeout.tv_sec = TIMEVAL_TV_SEC_MAX; 4546 timeout.tv_sec = TIMEVAL_TV_SEC_MAX;
4540 else 4547 else
4541#endif /* (SIZEOF_UINT64_T - 2) >= SIZEOF_STRUCT_TIMEVAL_TV_SEC */ 4548#endif /* (SIZEOF_UINT64_T - 2) >= SIZEOF_STRUCT_TIMEVAL_TV_SEC */
4542 timeout.tv_sec = (_MHD_TIMEVAL_TV_SEC_TYPE) (timeout64 / 1000); 4549 timeout.tv_sec = (_MHD_TIMEVAL_TV_SEC_TYPE) (select_tmo / 1000);
4543 4550
4544 timeout.tv_usec = ((uint16_t) (timeout64 % 1000)) * ((int32_t) 1000); 4551 timeout.tv_usec = ((uint16_t) (select_tmo % 1000)) * ((int32_t) 1000);
4545 } 4552 }
4546 } 4553 }
4547 num_ready = MHD_SYS_select_ (maxsock + 1, 4554 num_ready = MHD_SYS_select_ (maxsock + 1,