server_reschedule (session->plugin,
session->server_send->mhd_daemon,
GNUNET_YES);
- server_reschedule_session_timeout (session);
}
return bytes_sent;
}
}
+/**
+ * Function that is called to get the keepalive factor.
+ * GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT is divided by this number to
+ * calculate the interval between keepalive packets.
+ *
+ * @param cls closure with the `struct Plugin`
+ * @return keepalive factor
+ */
+static unsigned int
+http_server_query_keepalive_factor (void *cls)
+{
+ return 3;
+}
+
+static void
+http_server_plugin_update_session_timeout (void *cls,
+ const struct GNUNET_PeerIdentity *peer,
+ struct Session *session)
+{
+ struct HTTP_Server_Plugin *plugin = cls;
+
+ if (GNUNET_NO == server_exist_session (plugin, session))
+ return;
+
+ server_reschedule_session_timeout (session);
+}
+
+
/**
* Tell MHD that the connection should timeout after @a to seconds.
*
struct HTTP_Server_Plugin *plugin = cls;
struct HttpAddressWrapper *w = NULL;
- w = GNUNET_malloc (sizeof (struct HttpAddressWrapper));
+ w = GNUNET_new (struct HttpAddressWrapper);
w->address = http_common_address_from_socket (plugin->protocol, addr, addrlen);
if (NULL == w->address)
{
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
"Binding %s plugin to specific IPv4 address: `%s'\n",
plugin->protocol, bind4_address);
- plugin->server_addr_v4 = GNUNET_malloc (sizeof (struct sockaddr_in));
+ plugin->server_addr_v4 = GNUNET_new (struct sockaddr_in);
if (1 != inet_pton (AF_INET, bind4_address,
&plugin->server_addr_v4->sin_addr))
{
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
"Binding %s plugin to specific IPv6 address: `%s'\n",
plugin->protocol, bind6_address);
- plugin->server_addr_v6 = GNUNET_malloc (sizeof (struct sockaddr_in6));
+ plugin->server_addr_v6 = GNUNET_new (struct sockaddr_in6);
if (1 !=
inet_pton (AF_INET6, bind6_address, &plugin->server_addr_v6->sin6_addr))
{
return NULL;
}
-const char *http_plugin_address_to_string (void *cls,
- const void *addr,
- size_t addrlen)
+
+static const char *
+http_plugin_address_to_string (void *cls,
+ const void *addr,
+ size_t addrlen)
{
#if BUILD_HTTPS
- return http_common_plugin_address_to_string (cls, PLUGIN_NAME, addr, addrlen);
+ return http_common_plugin_address_to_string (cls, PLUGIN_NAME, addr, addrlen);
#else
- return http_common_plugin_address_to_string (cls, PLUGIN_NAME, addr, addrlen);
+ return http_common_plugin_address_to_string (cls, PLUGIN_NAME, addr, addrlen);
#endif
-
}
struct GNUNET_TRANSPORT_PluginFunctions *api;
struct HTTP_Server_Plugin *plugin;
- plugin = GNUNET_new (struct HTTP_Server_Plugin);
- plugin->env = env;
-
if (NULL == env->receive)
{
/* run in 'stub' mode (i.e. as part of gnunet-peerinfo), don't fully
api->address_pretty_printer = &http_common_plugin_address_pretty_printer;
return api;
}
-
+ plugin = GNUNET_new (struct HTTP_Server_Plugin);
+ plugin->env = env;
api = GNUNET_new (struct GNUNET_TRANSPORT_PluginFunctions);
api->cls = plugin;
api->send = &http_server_plugin_send;
api->disconnect_peer = &http_server_plugin_disconnect_peer;
api->disconnect_session = &http_server_plugin_disconnect_session;
+ api->query_keepalive_factor = &http_server_query_keepalive_factor;
api->check_address = &http_server_plugin_address_suggested;
api->get_session = &http_server_plugin_get_session;
api->string_to_address = &http_common_plugin_string_to_address;
api->address_pretty_printer = &http_common_plugin_address_pretty_printer;
api->get_network = &http_server_get_network;
-
+ api->update_session_timeout = &http_server_plugin_update_session_timeout;
#if BUILD_HTTPS
plugin->name = "transport-https_server";
plugin->protocol = "https";
/* Configure plugin */
if (GNUNET_SYSERR == server_configure_plugin (plugin))
{
- LIBGNUNET_PLUGIN_TRANSPORT_DONE (api);
- return NULL;
+ LIBGNUNET_PLUGIN_TRANSPORT_DONE (api);
+ return NULL;
}
/* Check IPv6 support */
if (GNUNET_SYSERR == server_start (plugin))
{
- LIBGNUNET_PLUGIN_TRANSPORT_DONE (api);
- return NULL;
+ LIBGNUNET_PLUGIN_TRANSPORT_DONE (api);
+ return NULL;
}
return api;
}