Handle imsg_read() EAGAIN like the man page code example.
authorrzalamena <rzalamena@openbsd.org>
Mon, 8 Aug 2016 16:49:17 +0000 (16:49 +0000)
committerrzalamena <rzalamena@openbsd.org>
Mon, 8 Aug 2016 16:49:17 +0000 (16:49 +0000)
ok reyk@

usr.sbin/switchd/control.c

index b5ee43c..0cf1422 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: control.c,v 1.2 2016/07/20 21:01:06 reyk Exp $        */
+/*     $OpenBSD: control.c,v 1.3 2016/08/08 16:49:17 rzalamena Exp $   */
 
 /*
  * Copyright (c) 2010-2016 Reyk Floeter <reyk@openbsd.org>
@@ -309,7 +309,8 @@ control_dispatch_imsg(int fd, short event, void *arg)
        }
 
        if (event & EV_READ) {
-               if ((n = imsg_read(&c->iev.ibuf)) == -1 || n == 0) {
+               if (((n = imsg_read(&c->iev.ibuf)) == -1 && errno != EAGAIN) ||
+                   n == 0) {
                        control_close(fd, cs);
                        return;
                }