[sr-dev] git:master:29c96974: mi_fifo: close reply stream in case of continuing due to no response

Daniel-Constantin Mierla miconda at gmail.com
Wed Nov 2 15:47:33 CET 2016


Module: kamailio
Branch: master
Commit: 29c96974fe80b1f19200314231f961fbf2689673
URL: https://github.com/kamailio/kamailio/commit/29c96974fe80b1f19200314231f961fbf2689673

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2016-11-02T15:37:50+01:00

mi_fifo: close reply stream in case of continuing due to no response

---

Modified: modules/mi_fifo/fifo_fnc.c

---

Diff:  https://github.com/kamailio/kamailio/commit/29c96974fe80b1f19200314231f961fbf2689673.diff
Patch: https://github.com/kamailio/kamailio/commit/29c96974fe80b1f19200314231f961fbf2689673.patch

---

diff --git a/modules/mi_fifo/fifo_fnc.c b/modules/mi_fifo/fifo_fnc.c
index eaa6cb7..aa0df20 100644
--- a/modules/mi_fifo/fifo_fnc.c
+++ b/modules/mi_fifo/fifo_fnc.c
@@ -407,13 +407,17 @@ void mi_fifo_server(FILE *fifo_stream)
 	int line_len;
 	char *file_sep, *command, *file;
 	struct mi_cmd *f;
-	FILE *reply_stream;
+	FILE *reply_stream = NULL;
 
 	while(1) {
 		/* update the local config framework structures */
 		cfg_update();
 
-		reply_stream = NULL;
+
+		if(reply_stream) {
+			fclose(reply_stream);
+			reply_stream = NULL;
+		}
 
 		/* commands must look this way ':<command>:[filename]' */
 		if (mi_read_line(mi_buf,MAX_MI_FIFO_BUFFER,fifo_stream, &line_len)) {
@@ -428,7 +432,7 @@ void mi_fifo_server(FILE *fifo_stream)
 				line_len--;
 				mi_buf[line_len]=0;
 			} else break;
-		} 
+		}
 
 		if (line_len==0) {
 			LM_DBG("fifo command empty\n");
@@ -525,6 +529,7 @@ void mi_fifo_server(FILE *fifo_stream)
 		free_async_handler(hdl);
 		/* close reply fifo */
 		fclose(reply_stream);
+		reply_stream = NULL;
 		/* destroy request tree */
 		if (mi_cmd)
 			free_mi_tree( mi_cmd );
@@ -542,9 +547,11 @@ void mi_fifo_server(FILE *fifo_stream)
 
 consume3:
 		free_async_handler(hdl);
-		if (reply_stream)
 consume2:
-		fclose(reply_stream);
+		if (reply_stream) {
+			fclose(reply_stream);
+			reply_stream = NULL;
+		}
 consume1:
 		mi_do_consume();
 	}




More information about the sr-dev mailing list