From 95c54276f76cd6b9bc628c2a484d9937813324ed Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 8 Feb 2017 08:26:07 -0500 Subject: [PATCH] zebra: Don't leak socket with failure condition 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 --- zebra/zebra_ptm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/zebra/zebra_ptm.c b/zebra/zebra_ptm.c index 446eb4953b..bc924842d4 100644 --- a/zebra/zebra_ptm.c +++ b/zebra/zebra_ptm.c @@ -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));