Skip to content

Commit

Permalink
jsonrpcs: close file for nice cleanup if fifo server fails to be init…
Browse files Browse the repository at this point in the history
…ialized
  • Loading branch information
miconda committed Jan 30, 2017
1 parent a473811 commit 35037a0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/modules/jsonrpcs/jsonrpcs_fifo.c
Expand Up @@ -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;
}

Expand Down

0 comments on commit 35037a0

Please sign in to comment.