|
@@ -338,7 +338,7 @@ void bev_connect(jsonrpc_server_t* server)
|
|
|
} else {
|
|
|
INFO("setting up socket");
|
|
|
fd = socket(AF_INET, SOCK_STREAM, 0);
|
|
|
- if (fd <= 0) {
|
|
|
+ if (fd < 0) {
|
|
|
server->keep_alive_socket_fd = -1;
|
|
|
ERR("could not setup socket");
|
|
|
} else {
|
|
@@ -346,6 +346,9 @@ void bev_connect(jsonrpc_server_t* server)
|
|
|
}
|
|
|
}
|
|
|
if (!fd_is_valid(fd)) { // make sure socket is valid
|
|
|
+ if (fd >= 0) {
|
|
|
+ close(fd);
|
|
|
+ }
|
|
|
fd = -1;
|
|
|
server->keep_alive_socket_fd = -1;
|
|
|
}
|