X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Ftransport%2Fplugin_transport_http_server.c;h=6a9c1b0baba318e9002aede5072a3ebdc1264ee8;hb=4bd01d03e323377bbbd7609e29d8179bcb682deb;hp=e3d5e9a017a564ffba71abe2db009c5f5377020c;hpb=1fc3df9be3dd51b14f752ea1a9e623aa781192bd;p=oweals%2Fgnunet.git diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c index e3d5e9a01..6a9c1b0ba 100644 --- a/src/transport/plugin_transport_http_server.c +++ b/src/transport/plugin_transport_http_server.c @@ -550,8 +550,8 @@ server_delete_session (struct GNUNET_ATS_Session *s) if (NULL != s->server_recv) { GNUNET_assert (s->server_recv->suspended); - MHD_resume_connection (s->server_recv->mhd_conn); s->server_recv->suspended = false; + MHD_resume_connection (s->server_recv->mhd_conn); } } GNUNET_assert (GNUNET_OK == @@ -589,6 +589,11 @@ server_delete_session (struct GNUNET_ATS_Session *s) MHD_set_connection_option (s->server_send->mhd_conn, MHD_CONNECTION_OPTION_TIMEOUT, 1 /* 0 = no timeout, so this is MIN */); + if (s->server_send->suspended) + { + s->server_send->suspended = false; + MHD_resume_connection (s->server_send->mhd_conn); + } server_reschedule (plugin, s->server_send->mhd_daemon, GNUNET_YES); @@ -1646,7 +1651,7 @@ server_send_callback (void *cls, * * @param cls current session as closure * @param message the message to be forwarded to transport service - * @return #GNUNET_OK + * @return #GNUNET_OK (all OK) */ static int server_receive_mst_cb (void *cls, @@ -1971,6 +1976,37 @@ server_disconnect_cb (void *cls, } +/** + * Callback from MHD when a connection starts/stops + * + * @param cls closure with the `struct HTTP_Server_Plugin *` + * @param connection connection handle + * @param socket_context socket-specific pointer + * @param toe reason for connection notification + * @see #MHD_OPTION_NOTIFY_CONNECTION + */ +static void +server_connection_cb (void *cls, + struct MHD_Connection *connection, + void **socket_context, + enum MHD_ConnectionNotificationCode toe) +{ + struct HTTP_Server_Plugin *plugin = cls; + const union MHD_ConnectionInfo *info; + + if (MHD_CONNECTION_NOTIFY_STARTED == toe) + return; + + /* Reschedule to remove closed socket from our select set */ + info = MHD_get_connection_info (connection, + MHD_CONNECTION_INFO_DAEMON); + GNUNET_assert (NULL != info); + server_reschedule (plugin, + info->daemon, + GNUNET_YES); +} + + /** * Check if incoming connection is accepted. * @@ -2252,6 +2288,8 @@ run_mhd_start_daemon (struct HTTP_Server_Plugin *plugin, GNUNET_MAX_MESSAGE_SIZE), MHD_OPTION_NOTIFY_COMPLETED, &server_disconnect_cb, plugin, + MHD_OPTION_NOTIFY_CONNECTION, + &server_connection_cb, plugin, MHD_OPTION_EXTERNAL_LOGGER, &server_log, NULL, MHD_OPTION_END);