Make sure that all poll loops properly restart the poll loop on EINTR.
authorclaudio <claudio@openbsd.org>
Thu, 20 Jan 2022 18:06:20 +0000 (18:06 +0000)
committerclaudio <claudio@openbsd.org>
Thu, 20 Jan 2022 18:06:20 +0000 (18:06 +0000)
Also either fail hard or restart after other errors. In anycase do not
look at pollfds after an error.
OK benno@

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

index b684cb4..537d491 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: bgpd.c,v 1.239 2021/07/20 12:07:46 claudio Exp $ */
+/*     $OpenBSD: bgpd.c,v 1.240 2022/01/20 18:06:20 claudio Exp $ */
 
 /*
  * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -345,11 +345,13 @@ BROKEN    if (pledge("stdio rpath wpath cpath fattr unix route recvfd sendfd",
 
                if (timeout < 0 || timeout > MAX_TIMEOUT)
                        timeout = MAX_TIMEOUT;
-               if (poll(pfd, npfd, timeout * 1000) == -1)
+               if (poll(pfd, npfd, timeout * 1000) == -1) {
                        if (errno != EINTR) {
                                log_warn("poll error");
                                quit = 1;
                        }
+                       continue;
+               }
 
                if (handle_pollfd(&pfd[PFD_PIPE_SESSION], ibuf_se) == -1) {
                        log_warnx("main: Lost connection to SE");
index 65696e2..0df5932 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: rde.c,v 1.532 2021/08/09 08:15:34 claudio Exp $ */
+/*     $OpenBSD: rde.c,v 1.533 2022/01/20 18:06:20 claudio Exp $ */
 
 /*
  * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -260,9 +260,9 @@ rde_main(int debug, int verbose)
                        timeout = 0;
 
                if (poll(pfd, i, timeout) == -1) {
-                       if (errno != EINTR)
-                               fatal("poll error");
-                       continue;
+                       if (errno == EINTR)
+                               continue;
+                       fatal("poll error");
                }
 
                if (handle_pollfd(&pfd[PFD_PIPE_MAIN], ibuf_main) == -1)
index 11f2741..ebfd88a 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: rtr.c,v 1.4 2021/09/01 12:39:52 claudio Exp $ */
+/*     $OpenBSD: rtr.c,v 1.5 2022/01/20 18:06:20 claudio Exp $ */
 
 /*
  * Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org>
@@ -167,9 +167,9 @@ rtr_main(int debug, int verbose)
                i += rtr_poll_events(pfd + i, pfd_elms - i, &timeout);
 
                if (poll(pfd, i, timeout * 1000) == -1) {
-                       if (errno != EINTR)
-                               fatal("poll error");
-                       continue;
+                       if (errno == EINTR)
+                               continue;
+                       fatal("poll error");
                }
 
                if (handle_pollfd(&pfd[PFD_PIPE_MAIN], ibuf_main) == -1)
index 6b2f3e5..6122466 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: session.c,v 1.424 2021/09/03 07:48:24 claudio Exp $ */
+/*     $OpenBSD: session.c,v 1.425 2022/01/20 18:06:20 claudio Exp $ */
 
 /*
  * Copyright (c) 2003, 2004, 2005 Henning Brauer <henning@openbsd.org>
@@ -452,9 +452,11 @@ session_main(int debug, int verbose)
                        timeout = 1;
                if (timeout < 0)
                        timeout = 0;
-               if (poll(pfd, i, timeout * 1000) == -1)
-                       if (errno != EINTR)
-                               fatal("poll error");
+               if (poll(pfd, i, timeout * 1000) == -1) {
+                       if (errno == EINTR)
+                               continue;
+                       fatal("poll error");
+               }
 
                /*
                 * If we previously saw fd exhaustion, we stop accept()