diff options
author | Thomas Haller <thaller@redhat.com> | 2014-11-12 14:31:56 +0100 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2014-11-12 17:48:37 -0600 |
commit | 2dfa722d42ab3aa777e469aa0b84933e87a69a01 (patch) | |
tree | dcfc811e5a0aefcbbd953a4828d5bb8046b4b4f5 | |
parent | 62b057974f3c127b91f17f37c3eaf34f3b83235e (diff) | |
download | NetworkManager-2dfa722d42ab3aa777e469aa0b84933e87a69a01.tar.gz |
firewall: invoke FwAddToZoneFunc callback also when cancelling
Not invoking a callback when cancelling the operation is counter
intuitive.
Note that NMPolicy refs the device, cancelling the call would leave
the reference hanging. That was not an issue because the call was
never cancelled. But still the behavior of NMFirewallManager is
unexpected.
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r-- | src/devices/nm-device.c | 13 | ||||
-rw-r--r-- | src/nm-firewall-manager.c | 11 |
2 files changed, 20 insertions, 4 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 6387e359dc..b3944372db 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -4527,8 +4527,14 @@ out: static void fw_change_zone_cb (GError *error, gpointer user_data) { - NMDevice *self = NM_DEVICE (user_data); - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); + NMDevice *self; + NMDevicePrivate *priv; + + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + return; + + self = NM_DEVICE (user_data); + priv = NM_DEVICE_GET_PRIVATE (self); priv->fw_call = NULL; @@ -4537,7 +4543,6 @@ fw_change_zone_cb (GError *error, gpointer user_data) } activation_source_schedule (self, nm_device_activate_stage3_ip_config_start, 0); - _LOGI (LOGD_DEVICE, "Activation: Stage 3 of 5 (IP Configure Start) scheduled."); } @@ -4559,6 +4564,8 @@ nm_device_activate_schedule_stage3_ip_config_start (NMDevice *self) priv = NM_DEVICE_GET_PRIVATE (self); g_return_if_fail (priv->act_request); + g_return_if_fail (!priv->fw_call); + /* Add the interface to the specified firewall zone */ connection = nm_device_get_connection (self); g_assert (connection); diff --git a/src/nm-firewall-manager.c b/src/nm-firewall-manager.c index bed77f40fb..ccd30cbca9 100644 --- a/src/nm-firewall-manager.c +++ b/src/nm-firewall-manager.c @@ -20,6 +20,7 @@ #include <string.h> #include <glib.h> +#include <gio/gio.h> #include <dbus/dbus.h> #include "nm-firewall-manager.h" @@ -69,9 +70,17 @@ cb_info_free (CBInfo *info) { g_return_if_fail (info != NULL); - if (!info->completed) + if (!info->completed) { nm_log_dbg (LOGD_FIREWALL, "(%s) firewall zone call cancelled [%u]", info->iface, info->id); + if (info->callback) { + GError *error; + error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_CANCELLED, + "Operation was cancelled"); + info->callback (error, info->user_data); + g_error_free (error); + } + } g_free (info->iface); g_free (info); } |