Browse code

core: execute event_route[core:worker-one-init] for sctp or tcp

- if no udp worker is started, the event route is executed by next
available transport, in the order: sctp, tcp (or tls)

Daniel-Constantin Mierla authored on 12/03/2021 17:15:34
Showing 3 changed files
... ...
@@ -13,8 +13,8 @@
13 13
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 14
  * GNU General Public License for more details.
15 15
  *
16
- * You should have received a copy of the GNU General Public License 
17
- * along with this program; if not, write to the Free Software 
16
+ * You should have received a copy of the GNU General Public License
17
+ * along with this program; if not, write to the Free Software
18 18
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19 19
  */
20 20
 
... ...
@@ -54,7 +54,7 @@ struct tcp_child{
54 54
 int init_tcp(void);
55 55
 void destroy_tcp(void);
56 56
 int tcp_init(struct socket_info* sock_info);
57
-int tcp_init_children(void);
57
+int tcp_init_children(int *woneinit);
58 58
 void tcp_main_loop(void);
59 59
 void tcp_receive_loop(int unix_sock);
60 60
 int tcp_fix_child_sockets(int* fd);
... ...
@@ -5034,16 +5034,16 @@ int tcp_fix_child_sockets(int* fd)
5034 5034
 
5035 5035
 
5036 5036
 /* starts the tcp processes */
5037
-int tcp_init_children()
5037
+int tcp_init_children(int *woneinit)
5038 5038
 {
5039 5039
 	int r, i;
5040 5040
 	int reader_fd_1; /* for comm. with the tcp children read  */
5041 5041
 	pid_t pid;
5042 5042
 	char si_desc[MAX_PT_DESC];
5043 5043
 	struct socket_info *si;
5044
-	
5044
+
5045 5045
 	/* estimate max fd. no:
5046
-	 * 1 tcp send unix socket/all_proc, 
5046
+	 * 1 tcp send unix socket/all_proc,
5047 5047
 	 *  + 1 udp sock/udp proc + 1 tcp_child sock/tcp child*
5048 5048
 	 *  + no_listen_tcp */
5049 5049
 	for(r=0, si=tcp_listen; si; si=si->next, r++);
... ...
@@ -5051,12 +5051,12 @@ int tcp_init_children()
5051 5051
 	if (! tls_disable)
5052 5052
 		for (si=tls_listen; si; si=si->next, r++);
5053 5053
 #endif
5054
-	
5054
+
5055 5055
 	register_fds(r+tcp_max_connections+get_max_procs()-1 /* tcp main */);
5056 5056
 #if 0
5057 5057
 	tcp_max_fd_no=get_max_procs()*2 +r-1 /* timer */ +3; /* stdin/out/err*/
5058 5058
 	/* max connections can be temporarily exceeded with estimated_process_count
5059
-	 * - tcp_main (tcpconn_connect called simultaneously in all all the 
5059
+	 * - tcp_main (tcpconn_connect called simultaneously in all all the
5060 5060
 	 *  processes) */
5061 5061
 	tcp_max_fd_no+=tcp_max_connections+get_max_procs()-1 /* tcp main */;
5062 5062
 #endif
... ...
@@ -5095,7 +5095,7 @@ int tcp_init_children()
5095 5095
 
5096 5096
 	/* create the tcp sock_info structures */
5097 5097
 	/* copy the sockets --moved to main_loop*/
5098
-	
5098
+
5099 5099
 	/* fork children & create the socket pairs*/
5100 5100
 	for(r=0; r<tcp_children_no; r++){
5101 5101
 		child_rank++;
... ...
@@ -5108,10 +5108,16 @@ int tcp_init_children()
5108 5108
 			goto error;
5109 5109
 		}else if (pid>0){
5110 5110
 			/* parent */
5111
+			*woneinit = 1;
5111 5112
 		}else{
5112 5113
 			/* child */
5113 5114
 			bind_address=0; /* force a SEGFAULT if someone uses a non-init.
5114 5115
 							   bind address on tcp */
5116
+			if(*woneinit==0) {
5117
+				if(run_child_one_init_route()<0)
5118
+					goto error;
5119
+			}
5120
+
5115 5121
 			tcp_receive_loop(reader_fd_1);
5116 5122
 		}
5117 5123
 	}
... ...
@@ -1720,8 +1720,14 @@ int main_loop(void)
1720 1720
 						/* child */
1721 1721
 						bind_address=si; /* shortcut */
1722 1722
 
1723
+						if(woneinit==0) {
1724
+							if(run_child_one_init_route()<0)
1725
+								goto error;
1726
+						}
1727
+
1723 1728
 						return sctp_core_rcv_loop();
1724 1729
 					}
1730
+					woneinit = 1;
1725 1731
 				}
1726 1732
 			/*parent*/
1727 1733
 			/*close(sctp_sock)*/; /*if closed=>sendto invalid fd errors?*/
... ...
@@ -1777,7 +1783,7 @@ int main_loop(void)
1777 1783
 #ifdef USE_TCP
1778 1784
 		if (!tcp_disable){
1779 1785
 				/* start tcp  & tls receivers */
1780
-			if (tcp_init_children()<0) goto error;
1786
+			if (tcp_init_children(&woneinit)<0) goto error;
1781 1787
 				/* start tcp+tls main attendant proc */
1782 1788
 			pid = fork_process(PROC_TCP_MAIN, "tcp main process", 0);
1783 1789
 			if (pid<0){