--- hal-0.4.2/hald/linux/osspec.c.hotplug 2005-12-01 15:17:29.000000000 -0500 +++ hal-0.4.2/hald/linux/osspec.c 2005-12-01 15:18:04.000000000 -0500 @@ -1443,15 +1443,21 @@ struct hald_helper_msg *msg; trynext: - if (hotplug_counter > 0) - return; /* Empty the list of events received while sleeping on the first hotplug event (this list is sorted) */ if (hotplug_queue_first != NULL) { msg = (struct hald_helper_msg *) hotplug_queue_first->data; HAL_INFO (("Processing event around first hotplug with SEQNUM=%llu", msg->seqnum)); - hald_helper_hotplug (msg->action, msg->seqnum, g_strdup (msg->subsystem), - g_strdup (msg->sysfs_path), msg); + if (msg->type == HALD_DEVD) { + hald_helper_device_name (msg->action, msg->seqnum, g_strdup (msg->subsystem), + g_strdup (msg->sysfs_path), g_strdup (msg->device_name), msg); + } else if (hotplug_counter == 0) { + hald_helper_hotplug (msg->action, msg->seqnum, g_strdup (msg->subsystem), + g_strdup (msg->sysfs_path), msg); + } else { + /* nothing else we can do until hotplug semaphore gets released */ + return; + } g_free (msg); hotplug_queue_first = g_list_delete_link (hotplug_queue_first, hotplug_queue_first); goto trynext; @@ -1460,26 +1466,40 @@ for (i = hotplug_queue; i != NULL; i = g_list_next (i)) { msg = (struct hald_helper_msg *) i->data; - /* check for dupes (user may have several hal.hotplug helpers (!) */ - if (msg->seqnum == last_hotplug_seqnum) { - HAL_WARNING (("******************************************")); - HAL_WARNING (("Ignoring duplicate event with SEQNUM=%d", msg->seqnum)); - HAL_WARNING (("******************************************")); + if ((msg->seqnum <= last_hotplug_seqnum) && (msg->type == HALD_DEVD)) { + /* + * we can process these messages even when hotplug_counter > 0, but we want + * to wait until we are processing the associated hotplug event to do so + */ + hald_helper_device_name (msg->action, msg->seqnum, g_strdup (msg->subsystem), + g_strdup (msg->sysfs_path), g_strdup (msg->device_name), msg); g_free (msg); hotplug_queue = g_list_delete_link (hotplug_queue, i); goto trynext; - } + } else if (hotplug_counter == 0) { - if (msg->seqnum == last_hotplug_seqnum + 1) { - /* yup, found it */ - last_hotplug_seqnum = msg->seqnum; - last_hotplug_time_stamp = msg->time_stamp; - hald_helper_hotplug (msg->action, msg->seqnum, g_strdup (msg->subsystem), - g_strdup (msg->sysfs_path), msg); - g_free (msg); - hotplug_queue = g_list_delete_link (hotplug_queue, i); - goto trynext; + /* check for dupes (user may have several hal.hotplug helpers (!) */ + if (msg->seqnum == last_hotplug_seqnum) { + HAL_WARNING (("******************************************")); + HAL_WARNING (("Ignoring duplicate event with SEQNUM=%d", msg->seqnum)); + HAL_WARNING (("******************************************")); + g_free (msg); + hotplug_queue = g_list_delete_link (hotplug_queue, i); + goto trynext; + } + + + if (msg->seqnum == last_hotplug_seqnum + 1) { + /* yup, found it */ + last_hotplug_seqnum = msg->seqnum; + last_hotplug_time_stamp = msg->time_stamp; + hald_helper_hotplug (msg->action, msg->seqnum, g_strdup (msg->subsystem), + g_strdup (msg->sysfs_path), msg); + g_free (msg); + hotplug_queue = g_list_delete_link (hotplug_queue, i); + goto trynext; + } } } } @@ -1608,6 +1628,9 @@ const struct hald_helper_msg *a = (const struct hald_helper_msg *) pa; const struct hald_helper_msg *b = (const struct hald_helper_msg *) pb; + if (a->seqnum == b->seqnum) { + return (gint) (a->type == HALD_DEVD ? 1 : -1); + } return (gint) (a->seqnum - b->seqnum); } @@ -1676,9 +1699,6 @@ switch (msg.type) { case HALD_DEVD: - hald_helper_device_name (msg.action, msg.seqnum, g_strdup (msg.subsystem), - g_strdup (msg.sysfs_path), g_strdup (msg.device_name), &msg); - break; case HALD_HOTPLUG: /* need to process hotplug events in proper sequence */