Re: dbus sleep/wake problem



On Mit, 2007-05-02 at 19:55 +0200, Michael Biebl wrote:
> Dawid Wróbel wrote:
> > Hi,
> > 	It seems that nm 0.6.5 has a problem with waking up from sleep
> > mode. What I did was:
> > 
> 
> I can confirm that. network-mnanager-(applet) does not autoconnect after
> suspend/resume.

We've also had problems with reconnecting to wireless networks after
resuming from suspend. Waiting five seconds with the real wakeup seems
to fix it; we haven't investigated the real cause of the problem yet.
The attached patch may help.

Regards,

Jürg
-- 
Jürg Billeter <j bitron ch>
diff -puNr NetworkManager-0.6.5.orig/src/nm-dbus-nm.c NetworkManager-0.6.5/src/nm-dbus-nm.c
--- NetworkManager-0.6.5.orig/src/nm-dbus-nm.c	2007-04-18 20:13:06.000000000 +0200
+++ NetworkManager-0.6.5/src/nm-dbus-nm.c	2007-04-29 10:12:55.000000000 +0200
@@ -593,10 +593,33 @@ static DBusMessage *nm_dbus_nm_sleep (DB
 	return NULL;
 }
 
+static gboolean nm_dbus_nm_wake_now (NMData *app_data) {
+	g_return_val_if_fail (app_data, FALSE);
+
+	if (!app_data->asleep)
+		return FALSE;
+
+	app_data->asleep = app_data->disconnected = FALSE;
+
+	/* Remove all devices from the device list */
+	nm_lock_mutex (app_data->dev_list_mutex, __FUNCTION__);
+	while (g_slist_length (app_data->dev_list))
+		nm_remove_device (app_data, (NMDevice *)(app_data->dev_list->data));
+	nm_unlock_mutex (app_data->dev_list_mutex, __FUNCTION__);
+
+	nm_add_initial_devices (app_data);
+
+	nm_schedule_state_change_signal_broadcast (app_data);
+	nm_policy_schedule_device_change_check (app_data);
+
+	return FALSE;
+}
+
 static DBusMessage *nm_dbus_nm_wake (DBusConnection *connection, DBusMessage *message, NMDbusCBData *data)
 {
 	NMData	*app_data;
 	DBusMessageIter iter;
+	GSource *source;
 	gboolean enable_networking = FALSE;
 
 	g_return_val_if_fail (data && data->data && connection && message, NULL);
@@ -621,23 +644,18 @@ static DBusMessage *nm_dbus_nm_wake (DBu
 	/* Restore networking only if we're not disconnected or
 	   enable_networking argument is passed. */
 	if (app_data->asleep && (!app_data->disconnected || enable_networking)) {
-		if (enable_networking)
+		if (enable_networking) {
 			nm_info ("Enabling networking.");
-		else
+			nm_dbus_nm_wake_now (app_data);
+		} else {
 			nm_info ("Waking up from sleep.");
 
-		app_data->asleep = app_data->disconnected = FALSE;
-
-		/* Remove all devices from the device list */
-		nm_lock_mutex (app_data->dev_list_mutex, __FUNCTION__);
-		while (g_slist_length (app_data->dev_list))
-			nm_remove_device (app_data, (NMDevice *)(app_data->dev_list->data));
-		nm_unlock_mutex (app_data->dev_list_mutex, __FUNCTION__);
-
-		nm_add_initial_devices (app_data);
-
-		nm_schedule_state_change_signal_broadcast (app_data);
-		nm_policy_schedule_device_change_check (data->data);
+			/* Delay wakeup a bit to make sure devices are ready. */
+			source = g_timeout_source_new (5000);
+			g_source_set_callback (source, nm_dbus_nm_wake_now, app_data, NULL);
+			g_source_attach (source, app_data->main_context);
+			g_source_unref (source);
+		}
 	}
 
 	return NULL;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]