quagga: restore socket status on error paths in zclient_read function
authorFerry Huberts <ferry.huberts@pelagic.nl>
Sat, 17 Oct 2015 20:41:29 +0000 (22:41 +0200)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Sun, 18 Oct 2015 18:17:45 +0000 (20:17 +0200)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/quagga/src/client.c

index 9d25ff8..922db9d 100644 (file)
@@ -177,6 +177,9 @@ zclient_read(ssize_t * size)
     bytes = read(zebra.sock, buf + *size, bufsize - *size);
     /* handle broken packet */
     if (!bytes) {
+      /* restore socket status */
+      (void)fcntl(zebra.sock, F_SETFL, sockstatus);
+
       free(buf);
       return NULL;
     }
@@ -188,6 +191,10 @@ zclient_read(ssize_t * size)
         zebra.status &= ~STATUS_CONNECTED;
         /* TODO: Remove HNAs added from redistribution */
       }
+
+      /* restore socket status */
+      (void)fcntl(zebra.sock, F_SETFL, sockstatus);
+
       free(buf);
       return NULL;
     }