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 938
 		for(si=udp_listen; si; si=si->next){
936 939
 			for(i=0;i<children_no;i++){
937 940
 				process_no++;
941
+				child_rank++;
938 942
 #ifdef USE_TCP
939 943
 				if(!tcp_disable){
940 944
 		 			if (socketpair(AF_UNIX, SOCK_STREAM, 0, sockfd)<0){
... ...
@@ -959,7 +963,7 @@ int main_loop()
959 963
 					 * parent gets a chance to set it*/
960 964
 					pt[process_no].pid=getpid();
961 965
 					bind_address=si; /* shortcut */
962
-					if (init_child(process_no) < 0) {
966
+					if (init_child(child_rank) < 0) {
963 967
 						LOG(L_ERR, "init_child failed\n");
964 968
 						goto error;
965 969
 					}
... ...
@@ -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 1742
 			/* record pid twice to avoid the child using it, before
1742 1743
 			 * parent gets a chance to set it*/
1743 1744
 			pt[process_no].pid=getpid();
1744
-			if (init_child(process_no) < 0) {
1745
+			if (init_child(child_rank) < 0) {
1745 1746
 				LOG(L_ERR, "init_children failed\n");
1746 1747
 				goto error;
1747 1748
 			}