From c194c1c3e0358ab9764725f861f698e37669d836 Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Tue, 25 May 2010 07:57:32 +0000 Subject: [PATCH] --- src/transport/plugin_transport_http.c | 23 +++++++++++++++++----- src/transport/test_plugin_transport_http.c | 2 +- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c index 5de55cd48..79ede78d1 100644 --- a/src/transport/plugin_transport_http.c +++ b/src/transport/plugin_transport_http.c @@ -25,6 +25,7 @@ */ #include "platform.h" +#include "gnunet_constants.h" #include "gnunet_protocols.h" #include "gnunet_connection_lib.h" #include "gnunet_server_lib.h" @@ -57,6 +58,11 @@ */ #define HTTP_ERROR_RESPONSE "404 Not Found

Not Found

The requested URL was not found on this server.


" +/** + * Timeout for a http connect + */ +#define HTTP_CONNECT_TIMEOUT 30 + /** * Encapsulation of all of the state of the plugin. @@ -627,6 +633,7 @@ http_plugin_send (void *cls, struct Session* ses; struct Session* ses_temp; int bytes_sent = 0; + unsigned int i_timeout; /* struct Plugin *plugin = cls; */ CURL *curl_handle; /* CURLcode res; */ @@ -673,17 +680,20 @@ http_plugin_send (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Getting cURL handle failed\n"); return -1; } + + i_timeout = ( timeout.value / 1000); + curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1L); curl_easy_setopt(curl_handle, CURLOPT_READFUNCTION, read_callback); curl_easy_setopt(curl_handle, CURLOPT_UPLOAD, 1L); curl_easy_setopt(curl_handle, CURLOPT_PUT, 1L); curl_easy_setopt(curl_handle, CURLOPT_URL, url); + curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, timeout); + curl_easy_setopt(curl_handle, CURLOPT_CONNECTTIMEOUT, HTTP_CONNECT_TIMEOUT); curl_easy_setopt(curl_handle, CURLOPT_READDATA, msgbuf); curl_easy_setopt(curl_handle, CURLOPT_INFILESIZE_LARGE, (curl_off_t)msgbuf_size); - - return bytes_sent; } @@ -844,7 +854,8 @@ libgnunet_plugin_transport_http_init (void *cls) { struct GNUNET_TRANSPORT_PluginEnvironment *env = cls; struct GNUNET_TRANSPORT_PluginFunctions *api; - + unsigned int timeout; + struct GNUNET_TIME_Relative gn_timeout; long long unsigned int port; plugin = GNUNET_malloc (sizeof (struct Plugin)); @@ -881,6 +892,8 @@ libgnunet_plugin_transport_http_init (void *cls) return NULL; } + gn_timeout = GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT; + timeout = ( gn_timeout.value / 1000); if ((http_daemon_v4 == NULL) && (http_daemon_v6 == NULL) && (port != 0)) { http_daemon_v6 = MHD_start_daemon (MHD_USE_IPv6, @@ -889,7 +902,7 @@ libgnunet_plugin_transport_http_init (void *cls) NULL , &accessHandlerCallback, NULL, MHD_OPTION_CONNECTION_LIMIT, (unsigned int) 16, MHD_OPTION_PER_IP_CONNECTION_LIMIT, (unsigned int) 1, - MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 16, + MHD_OPTION_CONNECTION_TIMEOUT, timeout, /* FIXME: set correct limit */ MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (16 * 1024), MHD_OPTION_NOTIFY_COMPLETED, &requestCompletedCallback, NULL, @@ -900,7 +913,7 @@ libgnunet_plugin_transport_http_init (void *cls) NULL , &accessHandlerCallback, NULL, MHD_OPTION_CONNECTION_LIMIT, (unsigned int) 16, MHD_OPTION_PER_IP_CONNECTION_LIMIT, (unsigned int) 1, - MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 16, + MHD_OPTION_CONNECTION_TIMEOUT, timeout, /* FIXME: set correct limit */ MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (16 * 1024), MHD_OPTION_NOTIFY_COMPLETED, &requestCompletedCallback, NULL, diff --git a/src/transport/test_plugin_transport_http.c b/src/transport/test_plugin_transport_http.c index be1a46885..9793420ac 100644 --- a/src/transport/test_plugin_transport_http.c +++ b/src/transport/test_plugin_transport_http.c @@ -235,7 +235,7 @@ task_timeout (void *cls, if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) return; - if ( timeout_count > 5 ) + if ( timeout_count > 15 ) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testcase timeout\n", timeout_count); fail = GNUNET_YES; -- 2.25.1