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.
This commit is contained in:
@@ -148,11 +148,19 @@ quit_timeout_cb (gpointer user_data)
|
|||||||
return FALSE;
|
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
|
static void
|
||||||
quit_timeout_reschedule (Handler *h)
|
quit_timeout_reschedule (Handler *h)
|
||||||
{
|
{
|
||||||
if (h->quit_id)
|
quit_timeout_cancel (h);
|
||||||
g_source_remove (h->quit_id);
|
|
||||||
if (!h->persist)
|
if (!h->persist)
|
||||||
h->quit_id = g_timeout_add_seconds (10, quit_timeout_cb, NULL);
|
h->quit_id = g_timeout_add_seconds (10, quit_timeout_cb, NULL);
|
||||||
}
|
}
|
||||||
@@ -165,8 +173,6 @@ next_script (gpointer user_data)
|
|||||||
GValueArray *item;
|
GValueArray *item;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
quit_timeout_reschedule (request->handler);
|
|
||||||
|
|
||||||
request->idx++;
|
request->idx++;
|
||||||
if (request->idx < request->scripts->len) {
|
if (request->idx < request->scripts->len) {
|
||||||
dispatch_one_script (request);
|
dispatch_one_script (request);
|
||||||
@@ -203,9 +209,11 @@ next_script (gpointer user_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
dbus_g_method_return (request->context, results);
|
dbus_g_method_return (request->context, results);
|
||||||
|
|
||||||
request_free (request);
|
|
||||||
g_ptr_array_unref (results);
|
g_ptr_array_unref (results);
|
||||||
|
|
||||||
|
quit_timeout_reschedule (request->handler);
|
||||||
|
request_free (request);
|
||||||
|
|
||||||
return FALSE;
|
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)) {
|
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_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 {
|
} else {
|
||||||
g_warning ("Failed to execute script '%s': (%d) %s",
|
g_warning ("Failed to execute script '%s': (%d) %s",
|
||||||
script->script, error->code, error->message);
|
script->script, error->code, error->message);
|
||||||
@@ -435,7 +443,7 @@ impl_dispatch (Handler *h,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
quit_timeout_reschedule (h);
|
quit_timeout_cancel (h);
|
||||||
|
|
||||||
request = g_malloc0 (sizeof (*request));
|
request = g_malloc0 (sizeof (*request));
|
||||||
request->handler = h;
|
request->handler = h;
|
||||||
|
@@ -342,7 +342,7 @@ _dispatcher_call (DispatcherAction action,
|
|||||||
dispatcher_done_cb,
|
dispatcher_done_cb,
|
||||||
info,
|
info,
|
||||||
(GDestroyNotify) dispatcher_info_free,
|
(GDestroyNotify) dispatcher_info_free,
|
||||||
15000,
|
30000,
|
||||||
G_TYPE_STRING, action_to_string (action),
|
G_TYPE_STRING, action_to_string (action),
|
||||||
DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, connection_hash,
|
DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, connection_hash,
|
||||||
DBUS_TYPE_G_MAP_OF_VARIANT, connection_props,
|
DBUS_TYPE_G_MAP_OF_VARIANT, connection_props,
|
||||||
|
Reference in New Issue
Block a user