Browse code

mi_fifo: start FIFO listener process using SR interface

- register one extra process to SR core
- start the extra process from child PROC_MAIN

Daniel-Constantin Mierla authored on 16/04/2009 16:16:04
Showing 1 changed files
... ...
@@ -43,6 +43,7 @@
43 43
 #include "../../sr_module.h"
44 44
 #include "../../dprint.h"
45 45
 #include "../../ut.h"
46
+#include "../../pt.h"
46 47
 #include "../../mem/mem.h"
47 48
 #include "../../mem/shm_mem.h"
48 49
 #include "../../lib/kmi/mi.h"
... ...
@@ -170,6 +171,9 @@ static int mi_mod_init(void)
170 171
 		}
171 172
 	}
172 173
 
174
+	/* add space for one extra process */
175
+	register_procs(1);
176
+
173 177
 	return 0;
174 178
 }
175 179
 
... ...
@@ -177,6 +181,8 @@ static int mi_mod_init(void)
177 181
 /*! \brief Initialize module for child processes */
178 182
 static int mi_child_init(int rank)
179 183
 {
184
+	int pid;
185
+
180 186
 	if (rank==PROC_TIMER || rank>0 ) {
181 187
 		if ( mi_writer_init(read_buf_size, mi_reply_indent)!=0 ) {
182 188
 			LM_CRIT("failed to init the reply writer\n");
... ...
@@ -184,6 +190,16 @@ static int mi_child_init(int rank)
184 190
 		}
185 191
 	}
186 192
 
193
+	if (rank==PROC_MAIN) {
194
+		pid=fork_process(100, "MI FIFO", 1);
195
+		if (pid<0)
196
+			return -1; /* error */
197
+		if(pid==0){
198
+			/* child */
199
+			fifo_process(1);
200
+		}
201
+	}
202
+
187 203
 	return 0;
188 204
 }
189 205