From: Matthias Wachs Date: Thu, 23 Feb 2012 16:01:08 +0000 (+0000) Subject: fix to the 100% CPU load problem X-Git-Tag: initial-import-from-subversion-38251~14696 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=308efe05ba94066c13062679089d9efe2fc22ee9;p=oweals%2Fgnunet.git fix to the 100% CPU load problem --- diff --git a/src/transport/plugin_transport_unix.c b/src/transport/plugin_transport_unix.c index e5ada0490..317ff2089 100644 --- a/src/transport/plugin_transport_unix.c +++ b/src/transport/plugin_transport_unix.c @@ -549,6 +549,18 @@ unix_plugin_get_session (void *cls, return s; } +/* + * @param cls the plugin handle + * @param tc the scheduling context (for rescheduling this function again) + * + * We have been notified that our writeset has something to read. We don't + * know which socket needs to be read, so we have to check each one + * Then reschedule this function to be called again once more is available. + * + */ +static void +unix_plugin_select (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); + /** * Function that can be used by the transport service to transmit * a message using the plugin. Note that in the case of a @@ -623,6 +635,17 @@ unix_plugin_send (void *cls, (char *) session->addr); #endif + if (plugin->select_task != GNUNET_SCHEDULER_NO_TASK) + GNUNET_SCHEDULER_cancel(plugin->select_task); + + plugin->select_task = + GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, + GNUNET_SCHEDULER_NO_TASK, + GNUNET_TIME_UNIT_FOREVER_REL, + plugin->rs, + plugin->ws, + &unix_plugin_select, plugin); + return ssize; } @@ -803,8 +826,10 @@ unix_plugin_select (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) plugin->select_task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, GNUNET_SCHEDULER_NO_TASK, - GNUNET_TIME_UNIT_FOREVER_REL, plugin->rs, - plugin->ws, &unix_plugin_select, plugin); + GNUNET_TIME_UNIT_FOREVER_REL, + plugin->rs, + (plugin->msg_head != NULL) ? plugin->ws : NULL, + &unix_plugin_select, plugin); } /**