]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: Don't leak socket with failure condition
authorDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 8 Feb 2017 13:26:07 +0000 (08:26 -0500)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 8 Feb 2017 13:26:07 +0000 (08:26 -0500)
Don't leak a socket when we are unable to set it
as non-blocking and warn the user as appropriate.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
zebra/zebra_ptm.c

index 446eb4953b8c80ac06d537d3ded3cf1e26342945..bc924842d44de3982c5c76461920555020f273e6 100644 (file)
@@ -388,7 +388,13 @@ zebra_ptm_socket_init (void)
   if (sock < 0)
     return -1;
   if (set_nonblocking(sock) < 0)
-    return -1;
+    {
+      if (IS_ZEBRA_DEBUG_EVENT)
+        zlog_debug ("%s: Unable to set socket non blocking[%s]",
+                    __PRETTY_FUNCTION__, safe_strerror (errno));
+      close (sock);
+      return -1;
+    }
 
   /* Make server socket. */
   memset (&addr, 0, sizeof (struct sockaddr_un));