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 <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2017-02-08 08:26:07 -05:00
parent 90d84f92ae
commit 95c54276f7

View 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));