Module: kamailio
Branch: master
Commit: b8b6c915a0f8d3f820e6c51a272ccd8d8c8f9ac7
URL:
https://github.com/kamailio/kamailio/commit/b8b6c915a0f8d3f820e6c51a272ccd8…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2022-04-22T13:05:54+02:00
janssonrpcc: close fd in case of error
---
Modified: src/modules/janssonrpcc/janssonrpc_connect.c
---
Diff:
https://github.com/kamailio/kamailio/commit/b8b6c915a0f8d3f820e6c51a272ccd8…
Patch:
https://github.com/kamailio/kamailio/commit/b8b6c915a0f8d3f820e6c51a272ccd8…
---
diff --git a/src/modules/janssonrpcc/janssonrpc_connect.c
b/src/modules/janssonrpcc/janssonrpc_connect.c
index 0ba40f1643..b6f4d69912 100644
--- a/src/modules/janssonrpcc/janssonrpc_connect.c
+++ b/src/modules/janssonrpcc/janssonrpc_connect.c
@@ -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;
}