diff options
author | Thomas Haller <thaller@redhat.com> | 2022-02-22 17:53:33 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2022-03-11 14:41:36 +0100 |
commit | 259adb3e3ac682d7b95b4a96a583c004d015cd45 (patch) | |
tree | fef20d6f4597f1833d1fb303c42052611aad0ca2 | |
parent | 239b3ca2abc9540e4e877b7f7eb32dcd6ddefa4f (diff) | |
download | NetworkManager-259adb3e3ac682d7b95b4a96a583c004d015cd45.tar.gz |
core: use GSource for timeout in nm_utils_kill_child_async()th/kill-child-log-warn
-rw-r--r-- | src/core/nm-core-utils.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/core/nm-core-utils.c b/src/core/nm-core-utils.c index 9b75519558..1fe2b6d13b 100644 --- a/src/core/nm-core-utils.c +++ b/src/core/nm-core-utils.c @@ -284,8 +284,8 @@ typedef struct { NMLogDomain log_domain; union { struct { - gint64 wait_start_us; - guint source_timeout_kill_id; + gint64 wait_start_us; + GSource *timeout_kill_source; } async; struct { gboolean success; @@ -376,8 +376,7 @@ _kc_cb_watch_child(GPid pid, int status, gpointer user_data) KillChildAsyncData *data = user_data; char buf_exit[KC_EXIT_TO_STRING_BUF_SIZE], buf_wait[KC_WAITED_TO_STRING]; - if (data->async.source_timeout_kill_id) - g_source_remove(data->async.source_timeout_kill_id); + nm_clear_g_source_inst(&data->async.timeout_kill_source); nm_log_dbg(data->log_domain, "%s: terminated %s%s", @@ -397,7 +396,7 @@ _kc_cb_timeout_grace_period(void *user_data) KillChildAsyncData *data = user_data; int ret, errsv; - data->async.source_timeout_kill_id = 0; + nm_clear_g_source_inst(&data->async.timeout_kill_source); if ((ret = kill(data->pid, SIGKILL)) != 0) { errsv = errno; @@ -417,7 +416,7 @@ _kc_cb_timeout_grace_period(void *user_data) (long) (nm_utils_get_monotonic_timestamp_usec() - data->async.wait_start_us)); } - return G_SOURCE_REMOVE; + return G_SOURCE_CONTINUE; } static gboolean @@ -564,8 +563,8 @@ nm_utils_kill_child_async(pid_t pid, data->async.wait_start_us = nm_utils_get_monotonic_timestamp_usec(); if (sig != SIGKILL && wait_before_kill_msec > 0) { - data->async.source_timeout_kill_id = - g_timeout_add(wait_before_kill_msec, _kc_cb_timeout_grace_period, data); + data->async.timeout_kill_source = + nm_g_timeout_add_source(wait_before_kill_msec, _kc_cb_timeout_grace_period, data); nm_log_dbg(log_domain, "%s: wait for process to terminate after sending %s (send SIGKILL in %ld " "milliseconds)...", @@ -573,7 +572,7 @@ nm_utils_kill_child_async(pid_t pid, _kc_signal_to_string(sig), (long) wait_before_kill_msec); } else { - data->async.source_timeout_kill_id = 0; + data->async.timeout_kill_source = NULL; nm_log_dbg(log_domain, "%s: wait for process to terminate after sending %s...", data->log_name, |