[PATCH] Remove idle callbacks in device_removed()


I have a scenario where an external script is powering down my
network device.  After the power down the script is restarting
HAL to work around an issue where occasionally new devices are
enumerated incorrectly.  Periodically this causes Network Manager
to crash in the idle callback since the device finalize method
had freed the device data.  This patch resolves the issue by
removing all idle callbacks in the device_removed() function.
I'm not sure if there are any side effects of doing this though.


Drew Moseley

diff --git a/src/NetworkManagerPolicy.c b/src/NetworkManagerPolicy.c
index 2de01f8..e554d14 100644
--- a/src/NetworkManagerPolicy.c
+++ b/src/NetworkManagerPolicy.c
@@ -860,9 +860,23 @@ static void
 device_removed (NMManager *manager, NMDevice *device, gpointer user_data)
 	NMPolicy *policy = (NMPolicy *) user_data;
-	GSList *iter = policy->dev_signal_ids;
+	GSList *iter;
+	/* Clear any idle callbacks for this device */
+	iter = policy->pending_activation_checks;
+	while (iter && iter->data) {
+		ActivateData *data = (ActivateData *) iter->data;
+		g_source_remove (data->id);
+		g_object_unref (data->device);
+		g_free (data);
+		iter = g_slist_next (iter);
+	}
+	g_slist_free (policy->pending_activation_checks);
+	policy->pending_activation_checks = NULL;
 	/* Clear any signal handlers for this device */
+	iter = policy->dev_signal_ids;
 	while (iter) {
 		DeviceSignalID *data = (DeviceSignalID *) iter->data;
 		GSList *next = g_slist_next (iter)

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