1 |
slords |
1.1 |
--- hal-0.4.2/hald/linux/osspec.c.hotplug 2005-12-01 15:17:29.000000000 -0500 |
2 |
|
|
+++ hal-0.4.2/hald/linux/osspec.c 2005-12-01 15:18:04.000000000 -0500 |
3 |
|
|
@@ -1443,15 +1443,21 @@ |
4 |
|
|
struct hald_helper_msg *msg; |
5 |
|
|
|
6 |
|
|
trynext: |
7 |
|
|
- if (hotplug_counter > 0) |
8 |
|
|
- return; |
9 |
|
|
|
10 |
|
|
/* Empty the list of events received while sleeping on the first hotplug event (this list is sorted) */ |
11 |
|
|
if (hotplug_queue_first != NULL) { |
12 |
|
|
msg = (struct hald_helper_msg *) hotplug_queue_first->data; |
13 |
|
|
HAL_INFO (("Processing event around first hotplug with SEQNUM=%llu", msg->seqnum)); |
14 |
|
|
- hald_helper_hotplug (msg->action, msg->seqnum, g_strdup (msg->subsystem), |
15 |
|
|
- g_strdup (msg->sysfs_path), msg); |
16 |
|
|
+ if (msg->type == HALD_DEVD) { |
17 |
|
|
+ hald_helper_device_name (msg->action, msg->seqnum, g_strdup (msg->subsystem), |
18 |
|
|
+ g_strdup (msg->sysfs_path), g_strdup (msg->device_name), msg); |
19 |
|
|
+ } else if (hotplug_counter == 0) { |
20 |
|
|
+ hald_helper_hotplug (msg->action, msg->seqnum, g_strdup (msg->subsystem), |
21 |
|
|
+ g_strdup (msg->sysfs_path), msg); |
22 |
|
|
+ } else { |
23 |
|
|
+ /* nothing else we can do until hotplug semaphore gets released */ |
24 |
|
|
+ return; |
25 |
|
|
+ } |
26 |
|
|
g_free (msg); |
27 |
|
|
hotplug_queue_first = g_list_delete_link (hotplug_queue_first, hotplug_queue_first); |
28 |
|
|
goto trynext; |
29 |
|
|
@@ -1460,26 +1466,40 @@ |
30 |
|
|
for (i = hotplug_queue; i != NULL; i = g_list_next (i)) { |
31 |
|
|
msg = (struct hald_helper_msg *) i->data; |
32 |
|
|
|
33 |
|
|
- /* check for dupes (user may have several hal.hotplug helpers (!) */ |
34 |
|
|
- if (msg->seqnum == last_hotplug_seqnum) { |
35 |
|
|
- HAL_WARNING (("******************************************")); |
36 |
|
|
- HAL_WARNING (("Ignoring duplicate event with SEQNUM=%d", msg->seqnum)); |
37 |
|
|
- HAL_WARNING (("******************************************")); |
38 |
|
|
+ if ((msg->seqnum <= last_hotplug_seqnum) && (msg->type == HALD_DEVD)) { |
39 |
|
|
+ /* |
40 |
|
|
+ * we can process these messages even when hotplug_counter > 0, but we want |
41 |
|
|
+ * to wait until we are processing the associated hotplug event to do so |
42 |
|
|
+ */ |
43 |
|
|
+ hald_helper_device_name (msg->action, msg->seqnum, g_strdup (msg->subsystem), |
44 |
|
|
+ g_strdup (msg->sysfs_path), g_strdup (msg->device_name), msg); |
45 |
|
|
g_free (msg); |
46 |
|
|
hotplug_queue = g_list_delete_link (hotplug_queue, i); |
47 |
|
|
goto trynext; |
48 |
|
|
- } |
49 |
|
|
|
50 |
|
|
+ } else if (hotplug_counter == 0) { |
51 |
|
|
|
52 |
|
|
- if (msg->seqnum == last_hotplug_seqnum + 1) { |
53 |
|
|
- /* yup, found it */ |
54 |
|
|
- last_hotplug_seqnum = msg->seqnum; |
55 |
|
|
- last_hotplug_time_stamp = msg->time_stamp; |
56 |
|
|
- hald_helper_hotplug (msg->action, msg->seqnum, g_strdup (msg->subsystem), |
57 |
|
|
- g_strdup (msg->sysfs_path), msg); |
58 |
|
|
- g_free (msg); |
59 |
|
|
- hotplug_queue = g_list_delete_link (hotplug_queue, i); |
60 |
|
|
- goto trynext; |
61 |
|
|
+ /* check for dupes (user may have several hal.hotplug helpers (!) */ |
62 |
|
|
+ if (msg->seqnum == last_hotplug_seqnum) { |
63 |
|
|
+ HAL_WARNING (("******************************************")); |
64 |
|
|
+ HAL_WARNING (("Ignoring duplicate event with SEQNUM=%d", msg->seqnum)); |
65 |
|
|
+ HAL_WARNING (("******************************************")); |
66 |
|
|
+ g_free (msg); |
67 |
|
|
+ hotplug_queue = g_list_delete_link (hotplug_queue, i); |
68 |
|
|
+ goto trynext; |
69 |
|
|
+ } |
70 |
|
|
+ |
71 |
|
|
+ |
72 |
|
|
+ if (msg->seqnum == last_hotplug_seqnum + 1) { |
73 |
|
|
+ /* yup, found it */ |
74 |
|
|
+ last_hotplug_seqnum = msg->seqnum; |
75 |
|
|
+ last_hotplug_time_stamp = msg->time_stamp; |
76 |
|
|
+ hald_helper_hotplug (msg->action, msg->seqnum, g_strdup (msg->subsystem), |
77 |
|
|
+ g_strdup (msg->sysfs_path), msg); |
78 |
|
|
+ g_free (msg); |
79 |
|
|
+ hotplug_queue = g_list_delete_link (hotplug_queue, i); |
80 |
|
|
+ goto trynext; |
81 |
|
|
+ } |
82 |
|
|
} |
83 |
|
|
} |
84 |
|
|
} |
85 |
|
|
@@ -1608,6 +1628,9 @@ |
86 |
|
|
const struct hald_helper_msg *a = (const struct hald_helper_msg *) pa; |
87 |
|
|
const struct hald_helper_msg *b = (const struct hald_helper_msg *) pb; |
88 |
|
|
|
89 |
|
|
+ if (a->seqnum == b->seqnum) { |
90 |
|
|
+ return (gint) (a->type == HALD_DEVD ? 1 : -1); |
91 |
|
|
+ } |
92 |
|
|
return (gint) (a->seqnum - b->seqnum); |
93 |
|
|
} |
94 |
|
|
|
95 |
|
|
@@ -1676,9 +1699,6 @@ |
96 |
|
|
|
97 |
|
|
switch (msg.type) { |
98 |
|
|
case HALD_DEVD: |
99 |
|
|
- hald_helper_device_name (msg.action, msg.seqnum, g_strdup (msg.subsystem), |
100 |
|
|
- g_strdup (msg.sysfs_path), g_strdup (msg.device_name), &msg); |
101 |
|
|
- break; |
102 |
|
|
case HALD_HOTPLUG: |
103 |
|
|
/* need to process hotplug events in proper sequence */ |
104 |
|
|
|