[package] broadcom-wl: check iface pid file when invoking nas, fixes starting nas...
[openwrt.git] / package / hotplug2 / patches / 140-worker_fork_fix.patch
1 --- a/action.c
2 +++ b/action.c
3 @@ -39,7 +39,7 @@ static void action_dumb(const struct set
4 * Returns: Newly allocated string in "key=value" form
5 *
6 */
7 -static char* alloc_env(const char *key, const char *value) {
8 +char* alloc_env(const char *key, const char *value) {
9 size_t keylen, vallen;
10 char *combined;
11
12 --- a/action.h
13 +++ b/action.h
14 @@ -12,5 +12,6 @@
15 #include "settings.h"
16
17 void action_perform(struct settings_t *, struct uevent_t *);
18 +char* alloc_env(const char *, const char *);
19 #endif /* ifndef ACTION_H */
20
21 --- a/workers/worker_fork.c
22 +++ b/workers/worker_fork.c
23 @@ -380,6 +380,7 @@ static void worker_fork_deinit(void *in_
24
25
26 static int worker_fork_process(void *in_ctx, struct uevent_t *uevent) {
27 + char **env;
28 int i;
29 struct worker_fork_child_t *child;
30 struct worker_fork_ctx_t *ctx = in_ctx;
31 @@ -406,6 +407,12 @@ static int worker_fork_process(void *in_
32 * No child process is currently available.
33 */
34 if (child == NULL) {
35 + env = xmalloc(sizeof(char *) * uevent->env_vars_c);
36 + for (i = 0; i < uevent->env_vars_c; i++) {
37 + env[i] = alloc_env(uevent->env_vars[i].key, uevent->env_vars[i].value);
38 + putenv(env[i]);
39 + }
40 +
41 /*
42 * Are the matching rules trivial enough that we
43 * can execute them in the main process?
44 @@ -421,6 +428,12 @@ static int worker_fork_process(void *in_
45 */
46 if (ctx->children_count < ctx->max_children)
47 child = worker_fork_spawn(ctx);
48 +
49 + for (i = 0; i < uevent->env_vars_c; i++) {
50 + unsetenv(uevent->env_vars[i].key);
51 + free(env[i]);
52 + }
53 + free(env);
54 }
55
56 /*
This page took 0.040008 seconds and 5 git commands to generate.