From d9334503d77167463edef8cf98445c3678271c5a Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Mon, 31 Mar 2014 08:38:06 -0400 Subject: [PATCH] dispatcher: bump script timeout up to 20 seconds (rh #1048345) The dispatcher would kill scripts after 3 seconds, but on heavily-loaded machines, that was sometimes too short even for simple scripts. Bump the timeout up to 20 seconds instead (and change the 10-second quit-on-idle timer to not run when a script is running). Also change the D-Bus call timeout in the daemon to 30 seconds, so that it only triggers if something goes really wrong and the action timeout fails. --- callouts/nm-dispatcher-action.c | 24 ++++++++++++++++-------- src/nm-dispatcher.c | 2 +- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/callouts/nm-dispatcher-action.c b/callouts/nm-dispatcher-action.c index f48ff0a23a..11aa5dc4f1 100644 --- a/callouts/nm-dispatcher-action.c +++ b/callouts/nm-dispatcher-action.c @@ -148,11 +148,19 @@ quit_timeout_cb (gpointer user_data) return FALSE; } +static void +quit_timeout_cancel (Handler *h) +{ + if (h->quit_id) { + g_source_remove (h->quit_id); + h->quit_id = 0; + } +} + static void quit_timeout_reschedule (Handler *h) { - if (h->quit_id) - g_source_remove (h->quit_id); + quit_timeout_cancel (h); if (!h->persist) h->quit_id = g_timeout_add_seconds (10, quit_timeout_cb, NULL); } @@ -165,8 +173,6 @@ next_script (gpointer user_data) GValueArray *item; guint i; - quit_timeout_reschedule (request->handler); - request->idx++; if (request->idx < request->scripts->len) { dispatch_one_script (request); @@ -203,9 +209,11 @@ next_script (gpointer user_data) } dbus_g_method_return (request->context, results); - - request_free (request); g_ptr_array_unref (results); + + quit_timeout_reschedule (request->handler); + request_free (request); + return FALSE; } @@ -353,7 +361,7 @@ dispatch_one_script (Request *request) if (g_spawn_async ("/", argv, request->envp, G_SPAWN_DO_NOT_REAP_CHILD, child_setup, request, &script->pid, &error)) { request->script_watch_id = g_child_watch_add (script->pid, (GChildWatchFunc) script_watch_cb, script); - request->script_timeout_id = g_timeout_add_seconds (3, script_timeout_cb, script); + request->script_timeout_id = g_timeout_add_seconds (20, script_timeout_cb, script); } else { g_warning ("Failed to execute script '%s': (%d) %s", script->script, error->code, error->message); @@ -435,7 +443,7 @@ impl_dispatch (Handler *h, return; } - quit_timeout_reschedule (h); + quit_timeout_cancel (h); request = g_malloc0 (sizeof (*request)); request->handler = h; diff --git a/src/nm-dispatcher.c b/src/nm-dispatcher.c index 7cf93f8411..a8fee1f3f3 100644 --- a/src/nm-dispatcher.c +++ b/src/nm-dispatcher.c @@ -342,7 +342,7 @@ _dispatcher_call (DispatcherAction action, dispatcher_done_cb, info, (GDestroyNotify) dispatcher_info_free, - 15000, + 30000, G_TYPE_STRING, action_to_string (action), DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, connection_hash, DBUS_TYPE_G_MAP_OF_VARIANT, connection_props,