summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ripd/rde.c
diff options
context:
space:
mode:
authorrenato <renato@openbsd.org>2016-09-03 10:28:08 +0000
committerrenato <renato@openbsd.org>2016-09-03 10:28:08 +0000
commitf6798567faf125f5cb86fc536eebc675ecca3a7f (patch)
tree2c5e71a32e8ec5f0ed79d8afd566416fc1ca8891 /usr.sbin/ripd/rde.c
parentSimplify shutdown process. (diff)
downloadwireguard-openbsd-f6798567faf125f5cb86fc536eebc675ecca3a7f.tar.xz
wireguard-openbsd-f6798567faf125f5cb86fc536eebc675ecca3a7f.zip
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/rde.c')
-rw-r--r--usr.sbin/ripd/rde.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/usr.sbin/ripd/rde.c b/usr.sbin/ripd/rde.c
index 70940d62a26..61085344060 100644
--- a/usr.sbin/ripd/rde.c
+++ b/usr.sbin/ripd/rde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.c,v 1.20 2016/09/02 14:07:52 benno Exp $ */
+/* $OpenBSD: rde.c,v 1.21 2016/09/03 10:28:08 renato Exp $ */
/*
* Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it>
@@ -45,7 +45,7 @@ struct imsgev *iev_ripe;
struct imsgev *iev_main;
void rde_sig_handler(int, short, void *);
-void rde_shutdown(void);
+__dead void rde_shutdown(void);
void rde_dispatch_imsg(int, short, void *);
void rde_dispatch_parent(int, short, void *);
int rde_imsg_compose_ripe(int, u_int32_t, pid_t, void *, u_int16_t);
@@ -159,14 +159,17 @@ rde(struct ripd_conf *xconf, int pipe_parent2rde[2], int pipe_ripe2rde[2],
return (0);
}
-void
+__dead void
rde_shutdown(void)
{
- rt_clear();
-
+ /* close pipes */
msgbuf_clear(&iev_ripe->ibuf.w);
- free(iev_ripe);
+ close(iev_ripe->ibuf.fd);
msgbuf_clear(&iev_main->ibuf.w);
+ close(iev_main->ibuf.fd);
+
+ rt_clear();
+ free(iev_ripe);
free(iev_main);
free(rdeconf);