Jelajahi Sumber

- 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 22 tahun lalu
induk
melakukan
7ec958f3ac
4 mengubah file dengan 30 tambahan dan 22 penghapusan
  1. 2 0
      TODO
  2. 5 13
      main.c
  3. 17 7
      tcp_main.c
  4. 6 2
      tcp_read.c

+ 2 - 0
TODO

@@ -14,6 +14,8 @@ x better Via parsing (handle ' ' in uri, eg: foo.bar : 1234 ; received=) and
 x (different way) add request header bitmap field for the modules
 x (different way) add request header bitmap field for the modules
 - introduce variables & function in the script language (cfg. file)
 - introduce variables & function in the script language (cfg. file)
 - ? variable number of params functions in script (no longer limited to 2)?
 - ? variable number of params functions in script (no longer limited to 2)?
+- kill bind_idx
+- fix bind_address for tcp (in some  way)
 
 
 
 
 High priority:
 High priority:

+ 5 - 13
main.c

@@ -26,10 +26,11 @@
  *
  *
  * History:
  * History:
  * -------
  * -------
- * 2002-01-29  argc/argv globalized via my_{argc|argv} (jiri)
- * 2003-01-23  mhomed added (jiri)
- * 2003-03-19  replaced all malloc/frees w/ pkg_malloc/pkg_free (andrei)
- * 2003-03-29  pkg cleaners for fifo and script callbacks introduced (jiri)
+ *  2002-01-29  argc/argv globalized via my_{argc|argv} (jiri)
+ *  2003-01-23  mhomed added (jiri)
+ *  2003-03-19  replaced all malloc/frees w/ pkg_malloc/pkg_free (andrei)
+ *  2003-03-29  pkg cleaners for fifo and script callbacks introduced (jiri)
+ *  2003-03-31  removed snmp part (obsolete & no place in core) (andrei)
  *
  *
  */
  */
 
 
@@ -598,15 +599,6 @@ int main_loop()
 #ifdef USE_TCP
 #ifdef USE_TCP
 	int sockfd[2];
 	int sockfd[2];
 #endif
 #endif
-#ifdef WITH_SNMP_MOD
-	int (*snmp_start)();
-
-	/* initialize snmp module */
-	snmp_start = (int(*)())find_export("snmp_start", 0);
-	if(snmp_start)
-		if(snmp_start() == -1)
-			LOG(L_ERR, "ERROR: Couldn't start snmp agent\n");
-#endif
 		
 		
 
 
 	/* one "main" process and n children handling i/o */
 	/* one "main" process and n children handling i/o */

+ 17 - 7
tcp_main.c

@@ -70,6 +70,7 @@
 #include "mem/mem.h"
 #include "mem/mem.h"
 #include "mem/shm_mem.h"
 #include "mem/shm_mem.h"
 #include "timer.h"
 #include "timer.h"
+#include "sr_module.h"
 #include "tcp_server.h"
 #include "tcp_server.h"
 #include "tcp_init.h"
 #include "tcp_init.h"
 
 
@@ -453,13 +454,15 @@ int tcp_init(struct socket_info* sock_info)
 #ifdef DISABLE_NAGLE
 #ifdef DISABLE_NAGLE
 	int flag;
 	int flag;
 	struct protoent* pe;
 	struct protoent* pe;
-	
-	pe=getprotobyname("tcp");
-	if (pe==0){
-		LOG(L_ERR, "ERROR: tcp_init: could not get TCP protocol number\n");
-		tcp_proto_no=-1;
-	}else{
-		tcp_proto_no=pe->p_proto;
+
+	if (tcp_proto_no==-1){ /* if not already set */
+		pe=getprotobyname("tcp");
+		if (pe==0){
+			LOG(L_ERR, "ERROR: tcp_init: could not get TCP protocol number\n");
+			tcp_proto_no=-1;
+		}else{
+			tcp_proto_no=pe->p_proto;
+		}
 	}
 	}
 #endif
 #endif
 	
 	
@@ -904,6 +907,13 @@ int tcp_init_children()
 			/* child */
 			/* child */
 			close(sockfd[0]);
 			close(sockfd[0]);
 			unix_tcp_sock=sockfd[1];
 			unix_tcp_sock=sockfd[1];
+			bind_address=0; /* force a SEGFAULT if someone uses a non-init.
+							   bind address on tcp */
+			bind_idx=0;
+			if (init_child(r+children_no) < 0) {
+				LOG(L_ERR, "init_child failed\n");
+				goto error;
+			}
 			tcp_receive_loop(sockfd[1]);
 			tcp_receive_loop(sockfd[1]);
 		}
 		}
 	}
 	}

+ 6 - 2
tcp_read.c

@@ -414,10 +414,14 @@ again:
 			}
 			}
 			/* if we are here everything is nice and ok*/
 			/* if we are here everything is nice and ok*/
 			resp=CONN_RELEASE;
 			resp=CONN_RELEASE;
-			/* just for debugging use sendipv4 as receiving socket */
 			DBG("calling receive_msg(%p, %d, )\n",
 			DBG("calling receive_msg(%p, %d, )\n",
 					req->start, (int)(req->parsed-req->start));
 					req->start, (int)(req->parsed-req->start));
-			bind_address=sendipv4; /*&tcp_info[con->sock_idx];*/
+			/* just for debugging use sendipv4 as receiving socket  FIXME*/
+			if (con->rcv.dst_ip.af==AF_INET6){
+				bind_address=sendipv6_tcp;
+			}else{
+				bind_address=sendipv4_tcp;
+			}
 			con->rcv.proto_reserved1=con->id; /* copy the id */
 			con->rcv.proto_reserved1=con->id; /* copy the id */
 			c=*req->parsed; /* ugly hack: zero term the msg & save the
 			c=*req->parsed; /* ugly hack: zero term the msg & save the
 							   previous char, req->parsed should be ok
 							   previous char, req->parsed should be ok