aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac31
-rw-r--r--src/microhttpd/daemon.c16
2 files changed, 44 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac
index b73f3cc3..6589b2d7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1072,6 +1072,37 @@ AC_CHECK_HEADER([[search.h]],
1072 1072
1073AM_CONDITIONAL([MHD_HAVE_TSEARCH], [[test "x$ac_cv_header_search_h" = xyes && test "x$HAVE_TSEARCH" = "x1" && test "x$REPLACE_TSEARCH" != "x1"]]) 1073AM_CONDITIONAL([MHD_HAVE_TSEARCH], [[test "x$ac_cv_header_search_h" = xyes && test "x$HAVE_TSEARCH" = "x1" && test "x$REPLACE_TSEARCH" != "x1"]])
1074 1074
1075# Check for types sizes
1076AC_CACHE_CHECK([size of tv_sec member of struct timeval], [mhd_cv_size_timeval_tv_sec],
1077 [
1078 AC_COMPUTE_INT([mhd_cv_size_timeval_tv_sec], [((long int)sizeof(test_var.tv_sec))],
1079 [[
1080#ifdef HAVE_SYS_TIME_H
1081#include <sys/time.h>
1082#endif /* HAVE_SYS_TIME_H */
1083#ifdef HAVE_TIME_H
1084#include <time.h>
1085#endif /* HAVE_TIME_H */
1086#if HAVE_SYS_TYPES_H
1087#include <sys/types.h>
1088#endif /* HAVE_SYS_TYPES_H */
1089static struct timeval test_var;
1090 ]],
1091 [
1092 # The size is used only to exclude additional checks/comparision in code
1093 # to avoid compiler warnings. With larger size MHD code will use
1094 # additional checks which ensure that value will fit but it may produce
1095 # a harmless compiler warning.
1096 AC_MSG_WARN([The size cannot be determined, assuming 8.])
1097 mhd_cv_size_timeval_tv_sec=8
1098 ]
1099 )
1100 ]
1101)
1102AC_DEFINE_UNQUOTED([SIZEOF_STRUCT_TIMEVAL_TV_SEC], [$mhd_cv_size_timeval_tv_sec],
1103 [The size of `tv_sec' member of `struct timeval', as computed by sizeof])
1104AC_CHECK_SIZEOF([uint64_t], [], [[#include <stdint.h>]])
1105
1075AC_CHECK_HEADERS([dlfcn.h],[have_tlsplugin=yes],[have_tlsplugin=no], [AC_INCLUDES_DEFAULT]) 1106AC_CHECK_HEADERS([dlfcn.h],[have_tlsplugin=yes],[have_tlsplugin=no], [AC_INCLUDES_DEFAULT])
1076AM_CONDITIONAL([MHD_HAVE_TLS_PLUGIN], [[test "x$have_tlsplugin" = xyes]]) 1107AM_CONDITIONAL([MHD_HAVE_TLS_PLUGIN], [[test "x$have_tlsplugin" = xyes]])
1077 1108
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 090d39d4..bec6d8d8 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -2008,12 +2008,13 @@ thread_main_handle_connection (void *data)
2008 else 2008 else
2009 { 2009 {
2010 const uint64_t mseconds_left = timeout - since_actv; 2010 const uint64_t mseconds_left = timeout - since_actv;
2011#if UINT64_MAX != TIMEVAL_TV_SEC_MAX 2011#if (SIZEOF_UINT64_T - 1) >= SIZEOF_STRUCT_TIMEVAL_TV_SEC
2012 if (mseconds_left / 1000 > TIMEVAL_TV_SEC_MAX) 2012 if (mseconds_left / 1000 > TIMEVAL_TV_SEC_MAX)
2013 tv.tv_sec = TIMEVAL_TV_SEC_MAX; 2013 tv.tv_sec = TIMEVAL_TV_SEC_MAX;
2014 else 2014 else
2015 tv.tv_sec = (_MHD_TIMEVAL_TV_SEC_TYPE) mseconds_left / 1000; 2015#endif /* (SIZEOF_UINT64_T - 1) >= SIZEOF_STRUCT_TIMEVAL_TV_SEC */
2016#endif /* UINT64_MAX != TIMEVAL_TV_SEC_MAX */ 2016 tv.tv_sec = (_MHD_TIMEVAL_TV_SEC_TYPE) mseconds_left / 1000;
2017
2017 tv.tv_usec = (mseconds_left % 1000) * 1000; 2018 tv.tv_usec = (mseconds_left % 1000) * 1000;
2018 } 2019 }
2019 tvp = &tv; 2020 tvp = &tv;
@@ -8143,6 +8144,15 @@ MHD_init (void)
8143 MHD_monotonic_sec_counter_init (); 8144 MHD_monotonic_sec_counter_init ();
8144 MHD_send_init_static_vars_ (); 8145 MHD_send_init_static_vars_ ();
8145 MHD_init_mem_pools_ (); 8146 MHD_init_mem_pools_ ();
8147 /* Check whether sizes were correctly detected by configure */
8148#ifdef _DEBUG
8149 if (1)
8150 {
8151 struct timeval tv;
8152 mhd_assert (sizeof(tv.tv_sec) == SIZEOF_STRUCT_TIMEVAL_TV_SEC);
8153 }
8154#endif /* _DEBUG */
8155 mhd_assert (sizeof(uint64_t) == SIZEOF_UINT64_T);
8146} 8156}
8147 8157
8148 8158