diff options
author | Renato Westphal <renato@cvs.openbsd.org> | 2016-09-03 10:28:09 +0000 |
---|---|---|
committer | Renato Westphal <renato@cvs.openbsd.org> | 2016-09-03 10:28:09 +0000 |
commit | a8c9cf9101f4dce10942d50b2b61b8fb74b077e3 (patch) | |
tree | ba3ef5f2ed7df641f491c6e20109ea1c5d96e56b /usr.sbin/ripd/ripe.c | |
parent | 2b10cc48e8e843e962ebe1faf6e6faee5507fad0 (diff) |
Simplify shutdown process.
On shutdown, there's no need to use kill(2) to kill the child
processes. Just closing the IPC sockets will make the children receive
an EOF, break out from the event loop and then exit.
Tha advantages of this "pipe teardown" are:
* simpler code;
* no need to pledge "proc" in the parent process;
* removal of a (hard to trigger) PID reuse race condition.
ok benno@ claudio@
Diffstat (limited to 'usr.sbin/ripd/ripe.c')
-rw-r--r-- | usr.sbin/ripd/ripe.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/usr.sbin/ripd/ripe.c b/usr.sbin/ripd/ripe.c index b70fb8c151c..2a10c003387 100644 --- a/usr.sbin/ripd/ripe.c +++ b/usr.sbin/ripd/ripe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ripe.c,v 1.21 2016/09/02 14:07:52 benno Exp $ */ +/* $OpenBSD: ripe.c,v 1.22 2016/09/03 10:28:08 renato Exp $ */ /* * Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it> @@ -43,7 +43,7 @@ #include "control.h" void ripe_sig_handler(int, short, void *); -void ripe_shutdown(void); +__dead void ripe_shutdown(void); struct ripd_conf *oeconf = NULL; struct imsgev *iev_main; @@ -450,11 +450,19 @@ ripe_dispatch_rde(int fd, short event, void *bula) } } -void +__dead void ripe_shutdown(void) { struct iface *iface; + /* close pipes */ + msgbuf_write(&iev_rde->ibuf.w); + msgbuf_clear(&iev_rde->ibuf.w); + close(iev_rde->ibuf.fd); + msgbuf_write(&iev_main->ibuf.w); + msgbuf_clear(&iev_main->ibuf.w); + close(iev_main->ibuf.fd); + LIST_FOREACH(iface, &oeconf->iface_list, entry) { if (if_fsm(iface, IF_EVT_DOWN)) { log_debug("error stopping interface %s", @@ -469,11 +477,7 @@ ripe_shutdown(void) close(oeconf->rip_socket); /* clean up */ - msgbuf_write(&iev_rde->ibuf.w); - msgbuf_clear(&iev_rde->ibuf.w); free(iev_rde); - msgbuf_write(&iev_main->ibuf.w); - msgbuf_clear(&iev_main->ibuf.w); free(iev_main); free(oeconf); free(pkt_ptr); |