summaryrefslogtreecommitdiff
path: root/src/anet.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/anet.c')
-rw-r--r--src/anet.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/anet.c b/src/anet.c
index ef1711d06..53a56b0d2 100644
--- a/src/anet.c
+++ b/src/anet.c
@@ -380,8 +380,10 @@ int anetUnixGenericConnect(char *err, char *path, int flags)
sa.sun_family = AF_LOCAL;
strncpy(sa.sun_path,path,sizeof(sa.sun_path)-1);
if (flags & ANET_CONNECT_NONBLOCK) {
- if (anetNonBlock(err,s) != ANET_OK)
+ if (anetNonBlock(err,s) != ANET_OK) {
+ close(s);
return ANET_ERR;
+ }
}
if (connect(s,(struct sockaddr*)&sa,sizeof(sa)) == -1) {
if (errno == EINPROGRESS &&
@@ -462,7 +464,7 @@ static int anetV6Only(char *err, int s) {
static int _anetTcpServer(char *err, int port, char *bindaddr, int af, int backlog)
{
- int s, rv;
+ int s = -1, rv;
char _port[6]; /* strlen("65535") */
struct addrinfo hints, *servinfo, *p;
@@ -491,6 +493,7 @@ static int _anetTcpServer(char *err, int port, char *bindaddr, int af, int backl
}
error:
+ if (s != -1) close(s);
s = ANET_ERR;
end:
freeaddrinfo(servinfo);