modem: don't warn if disconnect fails when the modem already failed
authorDan Williams <dcbw@redhat.com>
Mon, 4 Jun 2012 20:47:20 +0000 (15:47 -0500)
committerDan Williams <dcbw@redhat.com>
Mon, 4 Jun 2012 20:55:18 +0000 (15:55 -0500)
The disconnect request gets sent just as a precaution, but usually when
the device fails the modem is already gone from ModemManager and the
Disconnect() method will fail.  Just don't log the failure.

src/modem-manager/nm-modem.c

index b271133..c9c9e9a 100644 (file)
@@ -614,8 +614,9 @@ static void
 disconnect_done (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
 {
        GError *error = NULL;
+       gboolean warn = GPOINTER_TO_UINT (user_data);
 
-       if (!dbus_g_proxy_end_call (proxy, call_id, &error, G_TYPE_INVALID)) {
+       if (!dbus_g_proxy_end_call (proxy, call_id, &error, G_TYPE_INVALID) && warn) {
                nm_log_info (LOGD_MB, "disconnect failed: (%d) %s",
                             error ? error->code : -1,
                             error && error->message ? error->message : "(unknown)");
@@ -628,7 +629,7 @@ nm_modem_device_state_changed (NMModem *self,
                                NMDeviceState old_state,
                                NMDeviceStateReason reason)
 {
-       gboolean was_connected = FALSE;
+       gboolean was_connected = FALSE, warn = TRUE;
        NMModemPrivate *priv;
 
        g_return_if_fail (self != NULL);
@@ -658,10 +659,13 @@ nm_modem_device_state_changed (NMModem *self,
                }
 
                if (was_connected) {
+                       /* Don't bother warning on FAILED since the modem is already gone */
+                       if (new_state == NM_DEVICE_STATE_FAILED)
+                               warn = FALSE;
                        dbus_g_proxy_begin_call (nm_modem_get_proxy (self, MM_DBUS_INTERFACE_MODEM),
                                                 "Disconnect",
                                                 disconnect_done,
-                                                self,
+                                                GUINT_TO_POINTER (warn),
                                                 NULL,
                                                 G_TYPE_INVALID);
                }