Browse code

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

Jan Janak authored on 27/01/2006 09:52:58
Showing 3 changed files
... ...
@@ -94,6 +94,7 @@ extern int check_via;
94 94
 extern int received_dns;
95 95
 extern int syn_branch;
96 96
 /* extern int process_no; */
97
+extern int child_rank;
97 98
 extern int sip_warning;
98 99
 extern int server_signature;
99 100
 extern char* user;
... ...
@@ -332,6 +332,9 @@ struct host_alias* aliases=0; /* name aliases list */
332 332
 /* ipc related globals */
333 333
 int process_no = 0;
334 334
 
335
+/* Parameter to child_init */
336
+int child_rank = 0;
337
+
335 338
 /* Last filled entry in process table before calling
336 339
  * child_init of loaded modules
337 340
  */
... ...
@@ -935,6 +938,7 @@ int main_loop()
935 935
 		for(si=udp_listen; si; si=si->next){
936 936
 			for(i=0;i<children_no;i++){
937 937
 				process_no++;
938
+				child_rank++;
938 939
 #ifdef USE_TCP
939 940
 				if(!tcp_disable){
940 941
 		 			if (socketpair(AF_UNIX, SOCK_STREAM, 0, sockfd)<0){
... ...
@@ -959,7 +963,7 @@ int main_loop()
959 959
 					 * parent gets a chance to set it*/
960 960
 					pt[process_no].pid=getpid();
961 961
 					bind_address=si; /* shortcut */
962
-					if (init_child(process_no) < 0) {
962
+					if (init_child(child_rank) < 0) {
963 963
 						LOG(L_ERR, "init_child failed\n");
964 964
 						goto error;
965 965
 					}
... ...
@@ -1714,6 +1714,7 @@ int tcp_init_children()
1714 1714
 		}
1715 1715
 		
1716 1716
 		process_no++;
1717
+		child_rank++;
1717 1718
 		pid=fork();
1718 1719
 		if (pid<0){
1719 1720
 			LOG(L_ERR, "ERROR: tcp_main: fork failed: %s\n",
... ...
@@ -1741,7 +1742,7 @@ int tcp_init_children()
1741 1741
 			/* record pid twice to avoid the child using it, before
1742 1742
 			 * parent gets a chance to set it*/
1743 1743
 			pt[process_no].pid=getpid();
1744
-			if (init_child(process_no) < 0) {
1744
+			if (init_child(child_rank) < 0) {
1745 1745
 				LOG(L_ERR, "init_children failed\n");
1746 1746
 				goto error;
1747 1747
 			}