1 Index: hotplug2-0.9/hotplug2.c
2 ===================================================================
3 --- hotplug2-0.9.orig/hotplug2.c 2007-06-25 11:36:44.800185312 +0200
4 +++ hotplug2-0.9/hotplug2.c 2007-06-25 11:39:08.318367232 +0200
9 +static int action_needs_fork(struct hotplug2_event_t *event, struct rules_t *rules)
13 + for (i = 0; i < rules->rules_c; i++) {
14 + if (rule_needs_fork(event, &rules->rules[i]))
20 void perform_action(struct hotplug2_event_t *event, struct rules_t *rules) {
24 cur_seqnum = strtoull(seqnum, NULL, 0);
25 if (cur_seqnum > highest_seqnum)
26 highest_seqnum = cur_seqnum;
29 if ((dumb && tmpevent->action == ACTION_ADD && modalias != NULL) || (!dumb)) {
31 - * We have more children than we want. Wait until SIGCHLD handler reduces
34 - while (child_c >= max_child_c) {
35 - usleep(HOTPLUG2_THROTTLE_INTERVAL);
38 + if (!dumb && !action_needs_fork(tmpevent, rules))
42 + * We have more children than we want. Wait until SIGCHLD handler reduces
45 + while (child_c >= max_child_c) {
46 + usleep(HOTPLUG2_THROTTLE_INTERVAL);
50 sigemptyset(&block_mask);
54 DBG("spawn", "spawning: %d.", p);
55 - child = add_child(child, p, cur_seqnum);
58 + child = add_child(child, p, cur_seqnum);
63 sigprocmask(SIG_UNBLOCK, &block_mask, 0);
67 free_hotplug2_event(tmpevent);
70 Index: hotplug2-0.9/rules.c
71 ===================================================================
72 --- hotplug2-0.9.orig/rules.c 2007-06-25 11:36:44.801185160 +0200
73 +++ hotplug2-0.9/rules.c 2007-06-25 11:36:44.822181968 +0200
75 return EVAL_NOT_AVAILABLE;
78 +int rule_needs_fork(struct hotplug2_event_t *event, struct rule_t *rule)
82 + for (i = 0; i < rule->conditions_c; i++) {
83 + if (rule_condition_eval(event, &(rule->conditions[i])) != EVAL_MATCH)
86 + for (i = 0; i < rule->actions_c; i++) {
87 + switch (rule->actions[i].type) {
88 + case ACT_STOP_PROCESSING:
91 + case ACT_STOP_IF_FAILED:
95 + case ACT_NEXT_EVENT:
98 + case ACT_NEXT_IF_FAILED:
102 + case ACT_RUN_SHELL:
105 + case ACT_RUN_NOSHELL:
113 int rule_execute(struct hotplug2_event_t *event, struct rule_t *rule) {
116 Index: hotplug2-0.9/rules.h
117 ===================================================================
118 --- hotplug2-0.9.orig/rules.h 2007-06-25 11:36:44.801185160 +0200
119 +++ hotplug2-0.9/rules.h 2007-06-25 11:36:44.822181968 +0200
121 int rule_execute(struct hotplug2_event_t *, struct rule_t *);
122 void rules_free(struct rules_t *);
123 struct rules_t *rules_from_config(char *);
124 +int rule_needs_fork(struct hotplug2_event_t *event, struct rule_t *rule);
126 #endif /* ifndef RULES_H*/
127 Index: hotplug2-0.9/childlist.c
128 ===================================================================
129 --- hotplug2-0.9.orig/childlist.c 2007-06-25 11:40:23.477941240 +0200
130 +++ hotplug2-0.9/childlist.c 2007-06-25 11:40:48.164188360 +0200
132 struct hotplug2_child_t *remove_child_by_pid(struct hotplug2_child_t *child, pid_t pid, event_seqnum_t *largest_seqnum, int *child_c) {
133 struct hotplug2_child_t *tmp_child;
135 - if (child == NULL) {
136 - ERROR("remove_child_by_pid", "Invalid child list passed (NULL).");