dispatcher: improve debug logging for dispatcher callouts
- ensure, that dispatcher_results_process() logs a line even if no scripts were run. This way we alyways know when the callout returns. - log a line when cancelling a dispatcher call Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
@@ -203,6 +203,12 @@ dispatcher_results_process (guint request_id, GPtrArray *results)
|
|||||||
|
|
||||||
g_return_if_fail (results != NULL);
|
g_return_if_fail (results != NULL);
|
||||||
|
|
||||||
|
if (results->len == 0) {
|
||||||
|
nm_log_dbg (LOGD_DISPATCH, "(%u) succeeded but no scripts invoked",
|
||||||
|
request_id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < results->len; i++) {
|
for (i = 0; i < results->len; i++) {
|
||||||
GValueArray *item = g_ptr_array_index (results, i);
|
GValueArray *item = g_ptr_array_index (results, i);
|
||||||
GValue *tmp;
|
GValue *tmp;
|
||||||
@@ -221,8 +227,10 @@ dispatcher_results_process (guint request_id, GPtrArray *results)
|
|||||||
if (!validate_element (request_id, tmp, G_TYPE_STRING, i, 0))
|
if (!validate_element (request_id, tmp, G_TYPE_STRING, i, 0))
|
||||||
continue;
|
continue;
|
||||||
script = g_value_get_string (tmp);
|
script = g_value_get_string (tmp);
|
||||||
if (!script || strncmp (script, NMD_SCRIPT_DIR_DEFAULT "/", STRLEN (NMD_SCRIPT_DIR_DEFAULT "/")))
|
if (!script)
|
||||||
continue;
|
script = "(unknown)";
|
||||||
|
else if (!strncmp (script, NMD_SCRIPT_DIR_DEFAULT "/", STRLEN (NMD_SCRIPT_DIR_DEFAULT "/")))
|
||||||
|
script += STRLEN (NMD_SCRIPT_DIR_DEFAULT "/"),
|
||||||
|
|
||||||
/* Result */
|
/* Result */
|
||||||
tmp = g_value_array_get_nth (item, 1);
|
tmp = g_value_array_get_nth (item, 1);
|
||||||
@@ -240,11 +248,11 @@ dispatcher_results_process (guint request_id, GPtrArray *results)
|
|||||||
if (result == DISPATCH_RESULT_SUCCESS) {
|
if (result == DISPATCH_RESULT_SUCCESS) {
|
||||||
nm_log_dbg (LOGD_DISPATCH, "(%u) %s succeeded",
|
nm_log_dbg (LOGD_DISPATCH, "(%u) %s succeeded",
|
||||||
request_id,
|
request_id,
|
||||||
script + STRLEN (NMD_SCRIPT_DIR_DEFAULT "/"));
|
script);
|
||||||
} else {
|
} else {
|
||||||
nm_log_warn (LOGD_DISPATCH, "(%u) %s failed (%s): %s",
|
nm_log_warn (LOGD_DISPATCH, "(%u) %s failed (%s): %s",
|
||||||
request_id,
|
request_id,
|
||||||
script + STRLEN (NMD_SCRIPT_DIR_DEFAULT "/"),
|
script,
|
||||||
dispatch_result_to_string (result),
|
dispatch_result_to_string (result),
|
||||||
err ? err : "");
|
err ? err : "");
|
||||||
}
|
}
|
||||||
@@ -356,15 +364,21 @@ _dispatcher_call (DispatcherAction action,
|
|||||||
|
|
||||||
/* All actions except 'hostname' require a device */
|
/* All actions except 'hostname' require a device */
|
||||||
if (action == DISPATCHER_ACTION_HOSTNAME) {
|
if (action == DISPATCHER_ACTION_HOSTNAME) {
|
||||||
nm_log_dbg (LOGD_DISPATCH, "(%u) dispatching action '%s'",
|
nm_log_dbg (LOGD_DISPATCH, "(%u) dispatching action '%s'%s",
|
||||||
reqid, action_to_string (action));
|
reqid, action_to_string (action),
|
||||||
|
blocking
|
||||||
|
? " (blocking)"
|
||||||
|
: (callback ? " (with callback)" : ""));
|
||||||
} else {
|
} else {
|
||||||
g_return_val_if_fail (NM_IS_DEVICE (device), FALSE);
|
g_return_val_if_fail (NM_IS_DEVICE (device), FALSE);
|
||||||
|
|
||||||
nm_log_dbg (LOGD_DISPATCH, "(%u) (%s) dispatching action '%s'",
|
nm_log_dbg (LOGD_DISPATCH, "(%u) (%s) dispatching action '%s'%s",
|
||||||
reqid,
|
reqid,
|
||||||
vpn_iface ? vpn_iface : nm_device_get_iface (device),
|
vpn_iface ? vpn_iface : nm_device_get_iface (device),
|
||||||
action_to_string (action));
|
action_to_string (action),
|
||||||
|
blocking
|
||||||
|
? " (blocking)"
|
||||||
|
: (callback ? " (with callback)" : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* VPN actions require at least an IPv4 config (for now) */
|
/* VPN actions require at least an IPv4 config (for now) */
|
||||||
@@ -620,10 +634,13 @@ nm_dispatcher_call_cancel (guint call_id)
|
|||||||
* DispatcherInfo's callback to NULL.
|
* DispatcherInfo's callback to NULL.
|
||||||
*/
|
*/
|
||||||
info = g_hash_table_lookup (requests, GUINT_TO_POINTER (call_id));
|
info = g_hash_table_lookup (requests, GUINT_TO_POINTER (call_id));
|
||||||
if (info)
|
g_return_if_fail (info);
|
||||||
|
|
||||||
|
if (info && info->callback) {
|
||||||
|
nm_log_dbg (LOGD_DISPATCH, "(%u) cancelling dispatcher callback action",
|
||||||
|
call_id);
|
||||||
info->callback = NULL;
|
info->callback = NULL;
|
||||||
else
|
}
|
||||||
g_return_if_reached ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
Reference in New Issue
Block a user