Module: kamailio
Branch: master
Commit: 35037a00457c80d61b136510a362b36c7a5f90c0
URL:
https://github.com/kamailio/kamailio/commit/35037a00457c80d61b136510a362b36…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2017-01-30T17:40:38+01:00
jsonrpcs: close file for nice cleanup if fifo server fails to be initialized
---
Modified: src/modules/jsonrpcs/jsonrpcs_fifo.c
---
Diff:
https://github.com/kamailio/kamailio/commit/35037a00457c80d61b136510a362b36…
Patch:
https://github.com/kamailio/kamailio/commit/35037a00457c80d61b136510a362b36…
---
diff --git a/src/modules/jsonrpcs/jsonrpcs_fifo.c b/src/modules/jsonrpcs/jsonrpcs_fifo.c
index e399328..c44a55c 100644
--- a/src/modules/jsonrpcs/jsonrpcs_fifo.c
+++ b/src/modules/jsonrpcs/jsonrpcs_fifo.c
@@ -181,21 +181,25 @@ FILE *jsonrpc_init_fifo_server(char *fifo_name, int fifo_mode,
jsonrpc_fifo_write=open(fifo_name, O_WRONLY|O_NONBLOCK, 0);
if (jsonrpc_fifo_write<0) {
LM_ERR("fifo_write did not open: %s\n", strerror(errno));
+ fclose(fifo_stream);
return 0;
}
/* set read fifo blocking mode */
if ((opt=fcntl(jsonrpc_fifo_read, F_GETFL))==-1){
LM_ERR("fcntl(F_GETFL) failed: %s [%d]\n", strerror(errno), errno);
+ fclose(fifo_stream);
return 0;
}
if (fcntl(jsonrpc_fifo_read, F_SETFL, opt & (~O_NONBLOCK))==-1){
LM_ERR("cntl(F_SETFL) failed: %s [%d]\n", strerror(errno), errno);
+ fclose(fifo_stream);
return 0;
}
jsonrpc_reply_fifo_s = pkg_malloc(JSONRPC_MAX_FILENAME);
if (jsonrpc_reply_fifo_s==NULL) {
LM_ERR("no more private memory\n");
+ fclose(fifo_stream);
return 0;
}