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>
This commit is contained in:
Thomas Haller 2014-11-12 14:31:56 +01:00
parent b0b7473af1
commit 90a3332199
2 changed files with 20 additions and 4 deletions

View file

@ -4545,8 +4545,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;
@ -4555,7 +4561,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.");
}
@ -4577,6 +4582,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);

View file

@ -22,6 +22,7 @@
#include <string.h>
#include <glib.h>
#include <gio/gio.h>
#include <dbus/dbus.h>
#include "nm-firewall-manager.h"
@ -71,9 +72,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);
}