From 4e47209f522210ba808e4f873939440e503a9564 Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Tue, 29 May 2012 12:20:56 +0000 Subject: [PATCH] - no rescheduling when mhd is scheduled to run asap --- src/transport/plugin_transport_http.h | 11 +++++++++ src/transport/plugin_transport_http_server.c | 25 +++++++++++++------- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/transport/plugin_transport_http.h b/src/transport/plugin_transport_http.h index c3c9367ad..986d7d797 100644 --- a/src/transport/plugin_transport_http.h +++ b/src/transport/plugin_transport_http.h @@ -225,6 +225,11 @@ struct Plugin */ GNUNET_SCHEDULER_TaskIdentifier server_v4_task; + /** + * The IPv4 server is scheduled to run asap + */ + int server_v4_immediately; + /** * MHD IPv6 daemon */ @@ -235,6 +240,12 @@ struct Plugin */ GNUNET_SCHEDULER_TaskIdentifier server_v6_task; + /** + * The IPv6 server is scheduled to run asap + */ + + int server_v6_immediately; + /** * IPv4 server socket to bind to */ diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c index 272ecb645..b55c47582 100644 --- a/src/transport/plugin_transport_http_server.c +++ b/src/transport/plugin_transport_http_server.c @@ -236,6 +236,12 @@ server_reschedule (struct Plugin *plugin, struct MHD_Daemon *server, int now) { if ((server == plugin->server_v4) && (plugin->server_v4 != NULL)) { + if (GNUNET_YES == plugin->server_v4_immediately) + return; /* No rescheduling, server will run asap */ + + if (GNUNET_YES == now) + plugin->server_v4_immediately = GNUNET_YES; + if (plugin->server_v4_task != GNUNET_SCHEDULER_NO_TASK) { GNUNET_SCHEDULER_cancel (plugin->server_v4_task); @@ -246,6 +252,12 @@ server_reschedule (struct Plugin *plugin, struct MHD_Daemon *server, int now) if ((server == plugin->server_v6) && (plugin->server_v6 != NULL)) { + if (GNUNET_YES == plugin->server_v6_immediately) + return; /* No rescheduling, server will run asap */ + + if (GNUNET_YES == now) + plugin->server_v6_immediately = GNUNET_YES; + if (plugin->server_v6_task != GNUNET_SCHEDULER_NO_TASK) { GNUNET_SCHEDULER_cancel (plugin->server_v6_task); @@ -917,17 +929,15 @@ server_v4_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_assert (cls != NULL); plugin->server_v4_task = GNUNET_SCHEDULER_NO_TASK; - if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) return; #if 0 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, "Running IPv4 server\n"); #endif + plugin->server_v4_immediately = GNUNET_NO; GNUNET_assert (MHD_YES == MHD_run (plugin->server_v4)); - if (plugin->server_v4 != NULL) - plugin->server_v4_task = - server_schedule (plugin, plugin->server_v4, GNUNET_NO); + server_reschedule (plugin, plugin->server_v4, GNUNET_NO); } @@ -943,19 +953,16 @@ server_v6_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) struct Plugin *plugin = cls; GNUNET_assert (cls != NULL); - plugin->server_v6_task = GNUNET_SCHEDULER_NO_TASK; - if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) return; #if 0 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, "Running IPv6 server\n"); #endif + plugin->server_v6_immediately = GNUNET_NO; GNUNET_assert (MHD_YES == MHD_run (plugin->server_v6)); - if (plugin->server_v6 != NULL) - plugin->server_v6_task = - server_schedule (plugin, plugin->server_v6, GNUNET_NO); + server_reschedule (plugin, plugin->server_v6, GNUNET_NO); } /** -- 2.25.1