diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-09-29 09:26:23 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-09-29 09:26:23 +0000 |
commit | 80e57aec8d9a36444af5a2c64ec16eac965ce45f (patch) | |
tree | 1b4162425f4c593c390d7adef767bd15d242ff7b /src/transport | |
parent | 6d5c044aedd77a7131b2b5e099a583028a4598c6 (diff) | |
download | gnunet-80e57aec8d9a36444af5a2c64ec16eac965ce45f.tar.gz gnunet-80e57aec8d9a36444af5a2c64ec16eac965ce45f.zip |
setting default connection timeout depending on MHD version
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/plugin_transport_http_server.c | 37 |
1 files 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) | |||
76 | } | 76 | } |
77 | 77 | ||
78 | 78 | ||
79 | /** | ||
80 | * Callback called by MHD when it needs data to send | ||
81 | * @param cls current session | ||
82 | * @param pos position in buffer | ||
83 | * @param buf the buffer to write data to | ||
84 | * @param max max number of bytes available in buffer | ||
85 | * @return bytes written to buffer | ||
86 | */ | ||
87 | #if 0 | ||
88 | static ssize_t | ||
89 | server_send_cb (void *cls, uint64_t pos, char *buf, size_t max) | ||
90 | { | ||
91 | |||
92 | return 0; | ||
93 | } | ||
94 | #endif | ||
95 | |||
96 | |||
97 | #if BUILD_HTTPS | 79 | #if BUILD_HTTPS |
98 | static char * | 80 | static char * |
99 | server_load_file (const char *file) | 81 | server_load_file (const char *file) |
@@ -865,16 +847,29 @@ int | |||
865 | server_start (struct Plugin *plugin) | 847 | server_start (struct Plugin *plugin) |
866 | { | 848 | { |
867 | int res = GNUNET_OK; | 849 | int res = GNUNET_OK; |
850 | unsigned int timeout; | ||
868 | 851 | ||
869 | #if BUILD_HTTPS | 852 | #if BUILD_HTTPS |
870 | res = server_load_certificate (plugin); | 853 | res = server_load_certificate (plugin); |
871 | if (res == GNUNET_SYSERR) | 854 | if (res == GNUNET_SYSERR) |
872 | { | 855 | { |
873 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "TABORT\n"); | 856 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, |
857 | "Could not load or create server certificate! Loading plugin failed!\n"); | ||
874 | return res; | 858 | return res; |
875 | } | 859 | } |
876 | #endif | 860 | #endif |
877 | 861 | ||
862 | |||
863 | #if MHD_VERSION >= 0x00090E00 | ||
864 | timeout = 3; | ||
865 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | ||
866 | "MHD can set timeout per connection! Default time out %u sec.\n", timeout); | ||
867 | #else | ||
868 | timeout = GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value / 1000; | ||
869 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | ||
870 | "MHD cannot set timeout per connection! Default time out %u sec.\n", timeout); | ||
871 | #endif | ||
872 | |||
878 | plugin->server_v4 = NULL; | 873 | plugin->server_v4 = NULL; |
879 | if (plugin->ipv4 == GNUNET_YES) | 874 | if (plugin->ipv4 == GNUNET_YES) |
880 | { | 875 | { |
@@ -903,7 +898,7 @@ server_start (struct Plugin *plugin) | |||
903 | plugin->cert, | 898 | plugin->cert, |
904 | #endif | 899 | #endif |
905 | MHD_OPTION_CONNECTION_TIMEOUT, | 900 | MHD_OPTION_CONNECTION_TIMEOUT, |
906 | (unsigned int) 3, | 901 | timeout , |
907 | MHD_OPTION_CONNECTION_MEMORY_LIMIT, | 902 | MHD_OPTION_CONNECTION_MEMORY_LIMIT, |
908 | (size_t) (2 * | 903 | (size_t) (2 * |
909 | GNUNET_SERVER_MAX_MESSAGE_SIZE), | 904 | GNUNET_SERVER_MAX_MESSAGE_SIZE), |
@@ -942,7 +937,7 @@ server_start (struct Plugin *plugin) | |||
942 | plugin->cert, | 937 | plugin->cert, |
943 | #endif | 938 | #endif |
944 | MHD_OPTION_CONNECTION_TIMEOUT, | 939 | MHD_OPTION_CONNECTION_TIMEOUT, |
945 | (unsigned int) 3, | 940 | timeout, |
946 | MHD_OPTION_CONNECTION_MEMORY_LIMIT, | 941 | MHD_OPTION_CONNECTION_MEMORY_LIMIT, |
947 | (size_t) (2 * | 942 | (size_t) (2 * |
948 | GNUNET_SERVER_MAX_MESSAGE_SIZE), | 943 | GNUNET_SERVER_MAX_MESSAGE_SIZE), |