Refine the error handling

This commit is contained in:
Max Lv
2017-03-07 10:56:48 +08:00
parent 3f820c6fb8
commit e6799b98db
+6 -7
View File
@@ -391,6 +391,11 @@ create_server_socket(const char *host, const char *port)
rp = result;
if (rp == NULL) {
LOGE("[udp] cannot bind");
return -1;
}
/*
* On Linux, with net.ipv6.bindv6only = 0 (the default), getaddrinfo(NULL) with
* AI_PASSIVE returns 0.0.0.0 and :: (in this order). AI_PASSIVE was meant to
@@ -459,13 +464,7 @@ create_server_socket(const char *host, const char *port)
close(server_sock);
}
if (result)
freeaddrinfo(result);
if (rp == NULL) {
LOGE("[udp] cannot bind");
return -1;
}
freeaddrinfo(result);
return server_sock;
}