Browse code

bug fix: open_fifo_server now calls its init_child to make sure that modules' child initialization was done from fifo process prior to executing fifo commands

Jiri Kuthan authored on 27/08/2002 20:07:53
Showing 2 changed files
... ...
@@ -300,8 +300,8 @@ static void fifo_server(FILE *fifo_stream)
300 300
 			goto consume;
301 301
 		}
302 302
 		if (*buf!=CMD_SEPARATOR) {
303
-			LOG(L_ERR, "ERROR: fifo_server: command must start with %c\n", 
304
-				CMD_SEPARATOR);
303
+			LOG(L_ERR, "ERROR: fifo_server: command must begin with %c: %.*s\n", 
304
+				CMD_SEPARATOR, line_len, buf );
305 305
 			goto consume;
306 306
 		}
307 307
 		command=buf+1;
... ...
@@ -389,9 +389,16 @@ int open_fifo_server()
389 389
 	}
390 390
 	if (fifo_pid==0) { /* child == FIFO server */
391 391
 		LOG(L_INFO, "INFO: fifo process starting: %d\n", getpid());
392
+		/* call per-child module initialization too -- some
393
+		   FIFO commands may need it
394
+		*/
395
+		if (init_child(0) < 0 ) {
396
+			LOG(L_ERR, "ERROR: open_uac_fifo: init_child failed\n");
397
+			return -1;
398
+		}
392 399
 		fifo_read=open(fifo, O_RDONLY, 0);
393 400
 		if (fifo_read<0) {
394
-			LOG(L_ERR, "SER: open_uac_fifo: fifo_read did not open: %s\n",
401
+			LOG(L_ERR, "ERROR: open_uac_fifo: fifo_read did not open: %s\n",
395 402
 				strerror(errno));
396 403
 			return -1;
397 404
 		}
... ...
@@ -498,6 +498,12 @@ int main_loop()
498 498
 		pids[0]=getpid();
499 499
 		process_bit = 1;
500 500
 		process_no=0; /*main process number*/
501
+
502
+		/* if configured to do so, start a server for accepting FIFO commands */
503
+		if (open_fifo_server()<0) {
504
+			LOG(L_ERR, "opening fifo server failed\n");
505
+			goto error;
506
+		}
501 507
 		
502 508
 		     /* We will call child_init even if we
503 509
 		      * do not fork
... ...
@@ -508,11 +514,6 @@ int main_loop()
508 508
 			goto error;
509 509
 		}
510 510
 
511
-		/* if configured to do so, start a server for accepting FIFO commands */
512
-		if (open_fifo_server()<0) {
513
-			LOG(L_ERR, "opening fifo server failed\n");
514
-			goto error;
515
-		}
516 511
 		is_main=1; /* hack 42: call init_child with is_main=0 in case
517 512
 					 some modules wants to fork a child */
518 513