hal: Branch 'hal-0_5_11-branch'

Rob Taylor robtaylor at kemper.freedesktop.org
Mon Mar 17 12:18:55 PDT 2008


 hald/linux/coldplug.c |    4 -
 hald/linux/hotplug.c  |  121 ++++++++++----------------------------------------
 2 files changed, 26 insertions(+), 99 deletions(-)

New commits:
commit 16ab83ac9951a54529378e68fee7db8b619f9084
Author: Rob Taylor <rob.taylor at codethink.co.uk>
Date:   Mon Mar 17 13:46:34 2008 +0100

    Revert "process non-dependant hotplug events in parallel"
    
    This partially reverts commit 8fe3d44796d6aece0e3ce41d41587a99d206c876
    and dependant commit 07cfd3ad1e2fb4527ab46962dfef2244580e7903.
    
    Commit 8fe3d44796d6aece0e3ce41d41587a99d206c876 accidentally had two related
    peices of functionality, property_index support for HalDeviceStore and parallel
    event processing. This only reverts the parallel event processing part of the
    patch.

diff --git a/hald/linux/coldplug.c b/hald/linux/coldplug.c
index 7e65951..dbc1830 100644
--- a/hald/linux/coldplug.c
+++ b/hald/linux/coldplug.c
@@ -56,7 +56,7 @@ static GHashTable *sysfs_to_udev_map;
 static GSList *device_list;
 static char dev_root[HAL_PATH_MAX];
 static gchar *udevinfo_stdout = NULL;
-static unsigned long long coldplug_seqnum = 0;
+
 typedef struct _UdevInfo UdevInfo;
 
 struct _UdevInfo
@@ -309,8 +309,6 @@ no_node:
 	hotplug_event->action = HOTPLUG_ACTION_ADD;
 	hotplug_event->type = type;
 	hotplug_event->sysfs.net_ifindex = -1;
-	/*emulate sequence numbers for coldplug events*/
-	hotplug_event->sysfs.seqnum = coldplug_seqnum++;
 	return hotplug_event;
 }
 
diff --git a/hald/linux/hotplug.c b/hald/linux/hotplug.c
index 68b0eb2..2ca62ef 100644
--- a/hald/linux/hotplug.c
+++ b/hald/linux/hotplug.c
@@ -50,17 +50,17 @@
 #include "hotplug.h"
 
 /** Queue of ordered hotplug events */
-static GQueue *hotplug_event_queue = NULL;
+static GQueue *hotplug_event_queue;
 
 /** List of HotplugEvent objects we are currently processing */
-static GList *hotplug_events_in_progress = NULL;
+static GSList *hotplug_events_in_progress = NULL;
 
 void
 hotplug_event_end (void *end_token)
 {
 	HotplugEvent *hotplug_event = (HotplugEvent *) end_token;
 
-	hotplug_events_in_progress = g_list_remove (hotplug_events_in_progress, hotplug_event);
+	hotplug_events_in_progress = g_slist_remove (hotplug_events_in_progress, hotplug_event);
 
 	g_slice_free (HotplugEvent, hotplug_event);
 }
@@ -71,7 +71,7 @@ hotplug_event_reposted (void *end_token)
 	HotplugEvent *hotplug_event = (HotplugEvent *) end_token;
 
 	hotplug_event->reposted = TRUE;
-	hotplug_events_in_progress = g_list_remove (hotplug_events_in_progress, hotplug_event);
+	hotplug_events_in_progress = g_slist_remove (hotplug_events_in_progress, hotplug_event);
 }
 
 static void
@@ -310,7 +310,7 @@ hotplug_event_begin (HotplugEvent *hotplug_event)
 void 
 hotplug_event_enqueue (HotplugEvent *hotplug_event)
 {
-	if (G_UNLIKELY (hotplug_event_queue == NULL))
+	if (hotplug_event_queue == NULL)
 		hotplug_event_queue = g_queue_new ();
 
 	g_queue_push_tail (hotplug_event_queue, hotplug_event);
@@ -319,111 +319,40 @@ hotplug_event_enqueue (HotplugEvent *hotplug_event)
 void 
 hotplug_event_enqueue_at_front (HotplugEvent *hotplug_event)
 {
-	if (G_UNLIKELY (hotplug_event_queue == NULL))
+	if (hotplug_event_queue == NULL)
 		hotplug_event_queue = g_queue_new ();
 
 	g_queue_push_head (hotplug_event_queue, hotplug_event);
 }
 
-static gboolean
-compare_sysfspath(const char *running, const char *waiting)
-{
-	int i;
-
-	for (i = 0; i < HAL_PATH_MAX; i++) {
-		/* identical device event found */
-		if (running[i] == '\0' && waiting[i] == '\0')
-			return TRUE;
-
-		/* parent device event found */
-		if (running[i] == '\0' && waiting[i] == '/')
-			return TRUE;
-
-		/* child device event found */
-		if (running[i] == '/' && waiting[i] == '\0')
-			return TRUE;
-
-		/* no matching event */
-		if (running[i] != waiting[i])
-			break;
-	}
-
-	return FALSE;
-}
-
-/*
- * Returns TRUE if @eventl depends on @eventr
- */
-static gboolean
-compare_event (HotplugEvent *eventl, HotplugEvent *eventr)
-{
-	if (*eventl->sysfs.sysfs_path_old != '\0')
-		if (strcmp (eventr->sysfs.sysfs_path_old, eventl->sysfs.sysfs_path_old) == 0)
-			return TRUE;
-	return compare_sysfspath (eventr->sysfs.sysfs_path, eventl->sysfs.sysfs_path);
-}
-
-/*
- * Returns TRUE if @hotplug_event depends on any event in @events
- */
-static gboolean
-compare_events (HotplugEvent *hotplug_event, GList *events)
-{
-	GList *lp;
-	HotplugEvent *loop_event;
-
-	switch (hotplug_event->type) {
-
-	/* explicit fallthrough */
-	case HOTPLUG_EVENT_SYSFS:
-	case HOTPLUG_EVENT_SYSFS_DEVICE:
-	case HOTPLUG_EVENT_SYSFS_BLOCK:
-
-		for (lp = events; lp; lp = g_list_next (lp)) {
-			loop_event = (HotplugEvent*) lp->data;
-			/* skip ourselves and all later events*/
-			if (loop_event->sysfs.seqnum >= hotplug_event->sysfs.seqnum)
-				break;
-			if (compare_event (hotplug_event, loop_event)) {
-				HAL_DEBUG (("event %s dependant on %s", hotplug_event->sysfs.sysfs_path, loop_event->sysfs.sysfs_path));
-				return TRUE;
-			}
-		}
-		return FALSE;
-
-	default:
-		return FALSE;
-	}
-}
-
-
 void 
 hotplug_event_process_queue (void)
 {
 	HotplugEvent *hotplug_event;
-	GList *lp, *lp2;
 
-	if (G_UNLIKELY (hotplug_event_queue == NULL))
-		return;
+        while (hotplug_events_in_progress != NULL ||
+		(hotplug_event_queue != NULL &&
+		 !g_queue_is_empty (hotplug_event_queue))) {
 
-	for (lp = hotplug_event_queue->head; lp; lp = g_list_next (lp) ) {
-		hotplug_event = lp->data;
-		HAL_INFO (("checking event %s", hotplug_event->sysfs.sysfs_path));
-		if (!compare_events (hotplug_event, hotplug_event_queue->head)
-		 && !compare_events (hotplug_event, hotplug_events_in_progress)) {
-			lp2 = lp->prev;
-			g_queue_unlink(hotplug_event_queue, lp);
-			hotplug_events_in_progress = g_list_concat (hotplug_events_in_progress, lp);
-			hotplug_event_begin (hotplug_event);
-			lp = lp2;
-		} else {
-			HAL_DEBUG (("event held back: %s", hotplug_event->sysfs.sysfs_path));
-		}
-	}
-	HAL_DEBUG (("events queued = %d, events in progress = %d", hotplug_event_queue->length, g_list_length (hotplug_events_in_progress)));
+		/* do not process events if some other event is in progress 
+		 *
+		 * TODO: optimize so we can do add events in parallel by inspecting the
+		 *       wait_for_sysfs_path parameter and hotplug_events_in_progress list
+		 */
+		if (hotplug_events_in_progress != NULL && g_slist_length (hotplug_events_in_progress) > 0)
+			goto out;
 
+		hotplug_event = g_queue_pop_head (hotplug_event_queue);
+		if (hotplug_event == NULL)
+			goto out;
+
+		hotplug_events_in_progress = g_slist_append (hotplug_events_in_progress, hotplug_event);
+		hotplug_event_begin (hotplug_event);
+	}
 
 	hotplug_queue_now_empty ();
+out:
+        ;
 }
 
 gboolean 


More information about the hal-commit mailing list