Browse Source

- child_rank variable introduced to make parameter value to init_child more
predictable (needed especially in no fork mode)

Jan Janak 19 years ago
parent
commit
3167c7448b
3 changed files with 8 additions and 2 deletions
  1. 1 0
      globals.h
  2. 5 1
      main.c
  3. 2 1
      tcp_main.c

+ 1 - 0
globals.h

@@ -94,6 +94,7 @@ extern int check_via;
 extern int received_dns;
 extern int syn_branch;
 /* extern int process_no; */
+extern int child_rank;
 extern int sip_warning;
 extern int server_signature;
 extern char* user;

+ 5 - 1
main.c

@@ -332,6 +332,9 @@ struct host_alias* aliases=0; /* name aliases list */
 /* ipc related globals */
 int process_no = 0;
 
+/* Parameter to child_init */
+int child_rank = 0;
+
 /* Last filled entry in process table before calling
  * child_init of loaded modules
  */
@@ -935,6 +938,7 @@ int main_loop()
 		for(si=udp_listen; si; si=si->next){
 			for(i=0;i<children_no;i++){
 				process_no++;
+				child_rank++;
 #ifdef USE_TCP
 				if(!tcp_disable){
 		 			if (socketpair(AF_UNIX, SOCK_STREAM, 0, sockfd)<0){
@@ -959,7 +963,7 @@ int main_loop()
 					 * parent gets a chance to set it*/
 					pt[process_no].pid=getpid();
 					bind_address=si; /* shortcut */
-					if (init_child(process_no) < 0) {
+					if (init_child(child_rank) < 0) {
 						LOG(L_ERR, "init_child failed\n");
 						goto error;
 					}

+ 2 - 1
tcp_main.c

@@ -1714,6 +1714,7 @@ int tcp_init_children()
 		}
 		
 		process_no++;
+		child_rank++;
 		pid=fork();
 		if (pid<0){
 			LOG(L_ERR, "ERROR: tcp_main: fork failed: %s\n",
@@ -1741,7 +1742,7 @@ int tcp_init_children()
 			/* record pid twice to avoid the child using it, before
 			 * parent gets a chance to set it*/
 			pt[process_no].pid=getpid();
-			if (init_child(process_no) < 0) {
+			if (init_child(child_rank) < 0) {
 				LOG(L_ERR, "init_children failed\n");
 				goto error;
 			}