Browse Source

Initialization of the unixsock server moved before forking of UDP
listeners because they need to inhert open unix sockets

Jan Janak 21 năm trước cách đây
mục cha
commit
9e7eed4dd7
1 tập tin đã thay đổi với 10 bổ sung6 xóa
  1. 10 6
      main.c

+ 10 - 6
main.c

@@ -752,6 +752,7 @@ int main_loop()
 		/* process_no now initialized to zero -- increase from now on
 		   as new processes are forked (while skipping 0 reserved for main )
 		*/
+
 		for(si=udp_listen;si;si=si->next){
 			/* create the listening socket (for each address)*/
 			/* udp */
@@ -800,6 +801,15 @@ int main_loop()
 			/* all procs should have access to all the sockets (for sending)
 			 * so we open all first*/
 		if (do_suid()==-1) goto error; /* try to drop priviledges */
+
+		     /* Initialize Unix domain socket server before forking so that all
+		      * children inherit opened socket for sending and receiving
+		      */
+		if (init_unixsock_server()<0) {
+			LOG(L_ERR, "Error while initializing Unix domain socket server\n");
+			goto error;
+		}
+
 		/* udp processes */
 		for(si=udp_listen; si; si=si->next){
 			for(i=0;i<children_no;i++){
@@ -866,12 +876,6 @@ int main_loop()
 		goto error;
 	}
 
-	     /* Initialize Unix domain socket server */
-	if (init_unixsock_server()<0) {
-		LOG(L_ERR, "Error while initializing Unix domain socket server\n");
-		goto error;
-	}
-
 #ifdef USE_TCP
 	/* if we are using tcp we always need the timer */
 	if ((!tcp_disable)||(timer_list))