From 80e57aec8d9a36444af5a2c64ec16eac965ce45f Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Thu, 29 Sep 2011 09:26:23 +0000 Subject: [PATCH] setting default connection timeout depending on MHD version --- src/transport/plugin_transport_http_server.c | 37 +++++++++----------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c index 8303263f6..df913d5bb 100644 --- a/src/transport/plugin_transport_http_server.c +++ b/src/transport/plugin_transport_http_server.c @@ -76,24 +76,6 @@ server_accept_cb (void *cls, const struct sockaddr *addr, socklen_t addr_len) } -/** - * Callback called by MHD when it needs data to send - * @param cls current session - * @param pos position in buffer - * @param buf the buffer to write data to - * @param max max number of bytes available in buffer - * @return bytes written to buffer - */ -#if 0 -static ssize_t -server_send_cb (void *cls, uint64_t pos, char *buf, size_t max) -{ - - return 0; -} -#endif - - #if BUILD_HTTPS static char * server_load_file (const char *file) @@ -865,16 +847,29 @@ int server_start (struct Plugin *plugin) { int res = GNUNET_OK; + unsigned int timeout; #if BUILD_HTTPS res = server_load_certificate (plugin); if (res == GNUNET_SYSERR) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "TABORT\n"); + GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, + "Could not load or create server certificate! Loading plugin failed!\n"); return res; } #endif + +#if MHD_VERSION >= 0x00090E00 + timeout = 3; + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, + "MHD can set timeout per connection! Default time out %u sec.\n", timeout); +#else + timeout = GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value / 1000; + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, + "MHD cannot set timeout per connection! Default time out %u sec.\n", timeout); +#endif + plugin->server_v4 = NULL; if (plugin->ipv4 == GNUNET_YES) { @@ -903,7 +898,7 @@ server_start (struct Plugin *plugin) plugin->cert, #endif MHD_OPTION_CONNECTION_TIMEOUT, - (unsigned int) 3, + timeout , MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (2 * GNUNET_SERVER_MAX_MESSAGE_SIZE), @@ -942,7 +937,7 @@ server_start (struct Plugin *plugin) plugin->cert, #endif MHD_OPTION_CONNECTION_TIMEOUT, - (unsigned int) 3, + timeout, MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (2 * GNUNET_SERVER_MAX_MESSAGE_SIZE), -- 2.25.1