Close imsg pipes later in the process. The shutdown code still tires to
authorclaudio <claudio@openbsd.org>
Sun, 28 May 2017 20:10:59 +0000 (20:10 +0000)
committerclaudio <claudio@openbsd.org>
Sun, 28 May 2017 20:10:59 +0000 (20:10 +0000)
send imsgs and so the SE and RDE crashed because of this late in shutdown.
OK benno@ phessler@

usr.sbin/bgpd/rde.c
usr.sbin/bgpd/session.c

index c15b517..4b52cbf 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: rde.c,v 1.364 2017/05/28 12:21:36 claudio Exp $ */
+/*     $OpenBSD: rde.c,v 1.365 2017/05/28 20:10:59 claudio Exp $ */
 
 /*
  * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -321,6 +321,10 @@ rde_main(int debug, int verbose)
                        rde_dump_runner();
        }
 
+       /* do not clean up on shutdown on production, it takes ages. */
+       if (debug)
+               rde_shutdown();
+
        /* close pipes */
        if (ibuf_se) {
                msgbuf_clear(&ibuf_se->w);
@@ -336,10 +340,6 @@ rde_main(int debug, int verbose)
        close(ibuf_main->fd);
        free(ibuf_main);
 
-       /* do not clean up on shutdown on production, it takes ages. */
-       if (debug)
-               rde_shutdown();
-
        while ((mctx = LIST_FIRST(&rde_mrts)) != NULL) {
                msgbuf_clear(&mctx->mrt.wbuf);
                close(mctx->mrt.wbuf.fd);
index 6ec62d3..bbe20d1 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: session.c,v 1.362 2017/05/28 12:21:36 claudio Exp $ */
+/*     $OpenBSD: session.c,v 1.363 2017/05/28 20:10:59 claudio Exp $ */
 
 /*
  * Copyright (c) 2003, 2004, 2005 Henning Brauer <henning@openbsd.org>
@@ -544,23 +544,6 @@ session_main(int debug, int verbose)
                        control_dispatch_msg(&pfd[j], &ctl_cnt);
        }
 
-       /* close pipes */
-       if (ibuf_rde) {
-               msgbuf_write(&ibuf_rde->w);
-               msgbuf_clear(&ibuf_rde->w);
-               close(ibuf_rde->fd);
-               free(ibuf_rde);
-       }
-       if (ibuf_rde_ctl) {
-               msgbuf_clear(&ibuf_rde_ctl->w);
-               close(ibuf_rde_ctl->fd);
-               free(ibuf_rde_ctl);
-       }
-       msgbuf_write(&ibuf_main->w);
-       msgbuf_clear(&ibuf_main->w);
-       close(ibuf_main->fd);
-       free(ibuf_main);
-
        while ((p = peers) != NULL) {
                peers = p->next;
                strlcpy(p->conf.shutcomm,
@@ -586,6 +569,22 @@ session_main(int debug, int verbose)
        free(mrt_l);
        free(pfd);
 
+       /* close pipes */
+       if (ibuf_rde) {
+               msgbuf_write(&ibuf_rde->w);
+               msgbuf_clear(&ibuf_rde->w);
+               close(ibuf_rde->fd);
+               free(ibuf_rde);
+       }
+       if (ibuf_rde_ctl) {
+               msgbuf_clear(&ibuf_rde_ctl->w);
+               close(ibuf_rde_ctl->fd);
+               free(ibuf_rde_ctl);
+       }
+       msgbuf_write(&ibuf_main->w);
+       msgbuf_clear(&ibuf_main->w);
+       close(ibuf_main->fd);
+       free(ibuf_main);
 
        control_shutdown(csock);
        control_shutdown(rcsock);