diff options
| author | Roy Marples <roy@marples.name> | 2021-01-28 11:54:05 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2021-01-28 11:54:05 +0000 |
| commit | 11baa2a1f51c8da51883ab341f6e00e4f73c6998 (patch) | |
| tree | 4a069f765b1466d7e1e40003e73a716c12245429 /src/dhcpcd.c | |
| parent | 3ffb1dd5ee2a4962dd1384e00566996f791fcc78 (diff) | |
| download | dhcpcd-11baa2a1f51c8da51883ab341f6e00e4f73c6998.tar.xz | |
BSD: Implement kqueue(2) for eloop (again)
kqueue allows for O(1) processing of active fd's an a more
robust signal handling method without the need to use global
variables to avoid calling functions during signal delivery.
The problems with the prior implemenation have now been fixed.
Diffstat (limited to 'src/dhcpcd.c')
| -rw-r--r-- | src/dhcpcd.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/dhcpcd.c b/src/dhcpcd.c index 1cea184c..bd5a58d0 100644 --- a/src/dhcpcd.c +++ b/src/dhcpcd.c @@ -2335,6 +2335,7 @@ printpidfile: logerr("fork"); goto exit_failure; case 0: + eloop_forked(ctx.eloop); break; default: ctx.options |= DHCPCD_FORKED; /* A lie */ @@ -2575,9 +2576,6 @@ exit1: #endif freeifaddrs(ifaddrs); } - /* ps_stop will clear DHCPCD_PRIVSEP but we need to - * remember it to avoid attemping to remove the pidfile */ - oi = ctx.options & DHCPCD_PRIVSEP ? 1 : 0; #ifdef PRIVSEP ps_stop(&ctx); #endif @@ -2611,14 +2609,15 @@ exit1: #ifdef PLUGIN_DEV dev_stop(&ctx); #endif -#ifdef PRIVSEP - eloop_free(ctx.ps_eloop); -#endif - eloop_free(ctx.eloop); if (ctx.script != dhcpcd_default_script) free(ctx.script); if (ctx.options & DHCPCD_STARTED && !(ctx.options & DHCPCD_FORKED)) loginfox(PACKAGE " exited"); +#ifdef PRIVSEP + ps_root_stop(&ctx); + eloop_free(ctx.ps_eloop); +#endif + eloop_free(ctx.eloop); logclose(); free(ctx.logfile); free(ctx.ctl_buf); @@ -2632,7 +2631,7 @@ exit1: write(ctx.fork_fd, &i, sizeof(i)) == -1) logerr("%s: write", __func__); } - if (ctx.options & DHCPCD_FORKED || oi != 0) + if (ctx.options & (DHCPCD_FORKED | DHCPCD_PRIVSEP)) _exit(i); /* so atexit won't remove our pidfile */ #endif return i; |
