Browse code

- removed snmp relicts from core (main.c) - init_child is now called also for tcp receivers - tcp: bind_address is properly set to the correct address family or 0 if not init. (now bind_address will point to the first tcp ${AF} listen address -- to fix someday)

Andrei Pelinescu-Onciul authored on 31/03/2003 12:28:09
Showing 4 changed files
... ...
@@ -14,6 +14,8 @@ x better Via parsing (handle ' ' in uri, eg: foo.bar : 1234 ; received=) and
14 14
 x (different way) add request header bitmap field for the modules
15 15
 - introduce variables & function in the script language (cfg. file)
16 16
 - ? variable number of params functions in script (no longer limited to 2)?
17
+- kill bind_idx
18
+- fix bind_address for tcp (in some  way)
17 19
 
18 20
 
19 21
 High priority:
... ...
@@ -26,10 +26,11 @@
26 26
  *
27 27
  * History:
28 28
  * -------
29
- * 2002-01-29  argc/argv globalized via my_{argc|argv} (jiri)
30
- * 2003-01-23  mhomed added (jiri)
31
- * 2003-03-19  replaced all malloc/frees w/ pkg_malloc/pkg_free (andrei)
32
- * 2003-03-29  pkg cleaners for fifo and script callbacks introduced (jiri)
29
+ *  2002-01-29  argc/argv globalized via my_{argc|argv} (jiri)
30
+ *  2003-01-23  mhomed added (jiri)
31
+ *  2003-03-19  replaced all malloc/frees w/ pkg_malloc/pkg_free (andrei)
32
+ *  2003-03-29  pkg cleaners for fifo and script callbacks introduced (jiri)
33
+ *  2003-03-31  removed snmp part (obsolete & no place in core) (andrei)
33 34
  *
34 35
  */
35 36
 
... ...
@@ -598,15 +599,6 @@ int main_loop()
598 598
 #ifdef USE_TCP
599 599
 	int sockfd[2];
600 600
 #endif
601
-#ifdef WITH_SNMP_MOD
602
-	int (*snmp_start)();
603
-
604
-	/* initialize snmp module */
605
-	snmp_start = (int(*)())find_export("snmp_start", 0);
606
-	if(snmp_start)
607
-		if(snmp_start() == -1)
608
-			LOG(L_ERR, "ERROR: Couldn't start snmp agent\n");
609
-#endif
610 601
 		
611 602
 
612 603
 	/* one "main" process and n children handling i/o */
... ...
@@ -70,6 +70,7 @@
70 70
 #include "mem/mem.h"
71 71
 #include "mem/shm_mem.h"
72 72
 #include "timer.h"
73
+#include "sr_module.h"
73 74
 #include "tcp_server.h"
74 75
 #include "tcp_init.h"
75 76
 
... ...
@@ -453,13 +454,15 @@ int tcp_init(struct socket_info* sock_info)
453 453
 #ifdef DISABLE_NAGLE
454 454
 	int flag;
455 455
 	struct protoent* pe;
456
-	
457
-	pe=getprotobyname("tcp");
458
-	if (pe==0){
459
-		LOG(L_ERR, "ERROR: tcp_init: could not get TCP protocol number\n");
460
-		tcp_proto_no=-1;
461
-	}else{
462
-		tcp_proto_no=pe->p_proto;
456
+
457
+	if (tcp_proto_no==-1){ /* if not already set */
458
+		pe=getprotobyname("tcp");
459
+		if (pe==0){
460
+			LOG(L_ERR, "ERROR: tcp_init: could not get TCP protocol number\n");
461
+			tcp_proto_no=-1;
462
+		}else{
463
+			tcp_proto_no=pe->p_proto;
464
+		}
463 465
 	}
464 466
 #endif
465 467
 	
... ...
@@ -904,6 +907,13 @@ int tcp_init_children()
904 904
 			/* child */
905 905
 			close(sockfd[0]);
906 906
 			unix_tcp_sock=sockfd[1];
907
+			bind_address=0; /* force a SEGFAULT if someone uses a non-init.
908
+							   bind address on tcp */
909
+			bind_idx=0;
910
+			if (init_child(r+children_no) < 0) {
911
+				LOG(L_ERR, "init_child failed\n");
912
+				goto error;
913
+			}
907 914
 			tcp_receive_loop(sockfd[1]);
908 915
 		}
909 916
 	}
... ...
@@ -414,10 +414,14 @@ again:
414 414
 			}
415 415
 			/* if we are here everything is nice and ok*/
416 416
 			resp=CONN_RELEASE;
417
-			/* just for debugging use sendipv4 as receiving socket */
418 417
 			DBG("calling receive_msg(%p, %d, )\n",
419 418
 					req->start, (int)(req->parsed-req->start));
420
-			bind_address=sendipv4; /*&tcp_info[con->sock_idx];*/
419
+			/* just for debugging use sendipv4 as receiving socket  FIXME*/
420
+			if (con->rcv.dst_ip.af==AF_INET6){
421
+				bind_address=sendipv6_tcp;
422
+			}else{
423
+				bind_address=sendipv4_tcp;
424
+			}
421 425
 			con->rcv.proto_reserved1=con->id; /* copy the id */
422 426
 			c=*req->parsed; /* ugly hack: zero term the msg & save the
423 427
 							   previous char, req->parsed should be ok