aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_http_server.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-09-04 09:41:55 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-09-04 09:41:55 +0000
commitb7da788732aa32dc668be73460ebfd140076bbc7 (patch)
tree24ed90ce29aae13c658e8cd8cfd9d2aa6bacdbce /src/transport/plugin_transport_http_server.c
parent224ea9e3e94ce8762f9d1b081294d2d4cba0052b (diff)
downloadgnunet-b7da788732aa32dc668be73460ebfd140076bbc7.tar.gz
gnunet-b7da788732aa32dc668be73460ebfd140076bbc7.zip
mhd is failing to bind both IPv4 and IPv6 -> restructured http plugin to no fail if one fails
Diffstat (limited to 'src/transport/plugin_transport_http_server.c')
-rw-r--r--src/transport/plugin_transport_http_server.c73
1 files changed, 44 insertions, 29 deletions
diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c
index d102880eb..bcb8e53ae 100644
--- a/src/transport/plugin_transport_http_server.c
+++ b/src/transport/plugin_transport_http_server.c
@@ -2006,6 +2006,7 @@ static int
2006server_start (struct HTTP_Server_Plugin *plugin) 2006server_start (struct HTTP_Server_Plugin *plugin)
2007{ 2007{
2008 unsigned int timeout; 2008 unsigned int timeout;
2009 char *msg;
2009 GNUNET_assert (NULL != plugin); 2010 GNUNET_assert (NULL != plugin);
2010 2011
2011#if BUILD_HTTPS 2012#if BUILD_HTTPS
@@ -2029,22 +2030,23 @@ server_start (struct HTTP_Server_Plugin *plugin)
2029 "MHD cannot set timeout per connection! Default time out %u sec.\n", 2030 "MHD cannot set timeout per connection! Default time out %u sec.\n",
2030 timeout); 2031 timeout);
2031#endif 2032#endif
2032 plugin->server_v4 = NULL; 2033
2033 if (plugin->use_ipv4 == GNUNET_YES) 2034 plugin->server_v6 = NULL;
2035 if (plugin->use_ipv6 == GNUNET_YES)
2034 { 2036 {
2035 plugin->server_v4 = MHD_start_daemon ( 2037 plugin->server_v6 = MHD_start_daemon (
2036#if VERBOSE_SERVER 2038#if VERBOSE_SERVER
2037 MHD_USE_DEBUG | 2039 MHD_USE_DEBUG |
2038#endif 2040#endif
2039#if BUILD_HTTPS 2041#if BUILD_HTTPS
2040 MHD_USE_SSL | 2042 MHD_USE_SSL |
2041#endif 2043#endif
2042 MHD_NO_FLAG, plugin->port, 2044 MHD_USE_IPv6, plugin->port,
2043 &server_accept_cb, plugin, 2045 &server_accept_cb, plugin,
2044 &server_access_cb, plugin, 2046 &server_access_cb, plugin,
2045 MHD_OPTION_SOCK_ADDR, 2047 MHD_OPTION_SOCK_ADDR,
2046 (struct sockaddr_in *) 2048 (struct sockaddr_in6 *)
2047 plugin->server_addr_v4, 2049 plugin->server_addr_v6,
2048 MHD_OPTION_CONNECTION_LIMIT, 2050 MHD_OPTION_CONNECTION_LIMIT,
2049 (unsigned int) 2051 (unsigned int)
2050 plugin->max_connections, 2052 plugin->max_connections,
@@ -2065,23 +2067,32 @@ server_start (struct HTTP_Server_Plugin *plugin)
2065 &server_disconnect_cb, plugin, 2067 &server_disconnect_cb, plugin,
2066 MHD_OPTION_EXTERNAL_LOGGER, 2068 MHD_OPTION_EXTERNAL_LOGGER,
2067 server_log, NULL, MHD_OPTION_END); 2069 server_log, NULL, MHD_OPTION_END);
2070 if (plugin->server_v6 == NULL)
2071 {
2072 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
2073 "Failed to start %s IPv6 server component on port %u\n",
2074 plugin->name, plugin->port);
2075 }
2076 else
2077 server_reschedule (plugin, plugin->server_v6, GNUNET_NO);
2068 } 2078 }
2069 plugin->server_v6 = NULL; 2079
2070 if (plugin->use_ipv6 == GNUNET_YES) 2080 plugin->server_v4 = NULL;
2081 if (plugin->use_ipv4 == GNUNET_YES)
2071 { 2082 {
2072 plugin->server_v6 = MHD_start_daemon ( 2083 plugin->server_v4 = MHD_start_daemon (
2073#if VERBOSE_SERVER 2084#if VERBOSE_SERVER
2074 MHD_USE_DEBUG | 2085 MHD_USE_DEBUG |
2075#endif 2086#endif
2076#if BUILD_HTTPS 2087#if BUILD_HTTPS
2077 MHD_USE_SSL | 2088 MHD_USE_SSL |
2078#endif 2089#endif
2079 MHD_USE_IPv6, plugin->port, 2090 MHD_NO_FLAG, plugin->port,
2080 &server_accept_cb, plugin, 2091 &server_accept_cb, plugin,
2081 &server_access_cb, plugin, 2092 &server_access_cb, plugin,
2082 MHD_OPTION_SOCK_ADDR, 2093 MHD_OPTION_SOCK_ADDR,
2083 (struct sockaddr_in6 *) 2094 (struct sockaddr_in *)
2084 plugin->server_addr_v6, 2095 plugin->server_addr_v4,
2085 MHD_OPTION_CONNECTION_LIMIT, 2096 MHD_OPTION_CONNECTION_LIMIT,
2086 (unsigned int) 2097 (unsigned int)
2087 plugin->max_connections, 2098 plugin->max_connections,
@@ -2102,29 +2113,34 @@ server_start (struct HTTP_Server_Plugin *plugin)
2102 &server_disconnect_cb, plugin, 2113 &server_disconnect_cb, plugin,
2103 MHD_OPTION_EXTERNAL_LOGGER, 2114 MHD_OPTION_EXTERNAL_LOGGER,
2104 server_log, NULL, MHD_OPTION_END); 2115 server_log, NULL, MHD_OPTION_END);
2105 2116 if (plugin->server_v4 == NULL)
2106 } 2117 {
2107 2118 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
2108 if ((plugin->use_ipv4 == GNUNET_YES) && (plugin->server_v4 == NULL)) 2119 "Failed to start %s IPv4 server component on port %u\n",
2109 { 2120 plugin->name, plugin->port);
2110 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, 2121 }
2111 "Failed to start %s IPv4 server component on port %u\n", 2122 else
2112 plugin->name, plugin->port); 2123 server_reschedule (plugin, plugin->server_v4, GNUNET_NO);
2113 return GNUNET_SYSERR;
2114 } 2124 }
2115 server_reschedule (plugin, plugin->server_v4, GNUNET_NO);
2116 2125
2117 if ((plugin->use_ipv6 == GNUNET_YES) && (plugin->server_v6 == NULL)) 2126 msg = "No";
2127 if ((plugin->server_v6 == NULL) && (plugin->server_v6 == NULL))
2118 { 2128 {
2119 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, 2129 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
2120 "Failed to start %s IPv6 server component on port %u\n", 2130 "%s %s server component started on port %u\n",
2121 plugin->name, plugin->port); 2131 msg, plugin->name, plugin->port);
2122 return GNUNET_SYSERR; 2132 return GNUNET_SYSERR;
2123 } 2133 }
2124 server_reschedule (plugin, plugin->server_v6, GNUNET_NO); 2134 else if ((plugin->server_v6 != NULL) && (plugin->server_v6 != NULL))
2135 msg = "IPv4 and IPv6";
2136 else if (plugin->server_v6 != NULL)
2137 msg = "IPv6";
2138 else if (plugin->server_v4 != NULL)
2139 msg = "IPv4";
2125 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, 2140 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
2126 "%s server component started on port %u\n", plugin->name, 2141 "%s %s server component started on port %u\n",
2127 plugin->port); 2142 msg, plugin->name, plugin->port);
2143
2128 return GNUNET_OK; 2144 return GNUNET_OK;
2129} 2145}
2130 2146
@@ -3124,7 +3140,6 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls)
3124 LIBGNUNET_PLUGIN_TRANSPORT_DONE (api); 3140 LIBGNUNET_PLUGIN_TRANSPORT_DONE (api);
3125 return NULL; 3141 return NULL;
3126 } 3142 }
3127
3128 return api; 3143 return api;
3129} 3144}
3130 3145