2
0
Эх сурвалжийг харах

- fixed F_CONN_REMOVED flag reset to 0
- struct tcp_connection re-arrangement + sign/unsigned fixes

Andrei Pelinescu-Onciul 20 жил өмнө
parent
commit
7564dcaba5
3 өөрчлөгдсөн 12 нэмэгдсэн , 12 устгасан
  1. 1 1
      Makefile.defs
  2. 3 3
      tcp_conn.h
  3. 8 8
      tcp_main.c

+ 1 - 1
Makefile.defs

@@ -61,7 +61,7 @@ MAIN_NAME=ser
 VERSION = 0
 PATCHLEVEL = 10
 SUBLEVEL =   99
-EXTRAVERSION = -dev22-tcp
+EXTRAVERSION = -dev23-tcp
 
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")

+ 3 - 3
tcp_conn.h

@@ -126,14 +126,14 @@ struct tcp_connection{
 	int flags; /* connection related flags */
 	enum tcp_conn_states state; /* connection state */
 	void* extra_data; /* extra data associated to the connection, 0 for tcp*/
-	int timeout; /* connection timeout, after this it will be removed*/
+	unsigned int timeout;/* connection timeout, after this it will be removed*/
 	unsigned id_hash; /* hash index in the id_hash */
-	int aliases; /* aliases number, at least 1 */
-	struct tcp_conn_alias con_aliases[TCP_CON_MAX_ALIASES];
 	struct tcp_connection* id_next; /* next, prev in id hash table */
 	struct tcp_connection* id_prev;
 	struct tcp_connection* c_next; /* child next prev (use locally) */
 	struct tcp_connection* c_prev;
+	struct tcp_conn_alias con_aliases[TCP_CON_MAX_ALIASES];
+	int aliases; /* aliases number, at least 1 */
 };
 
 

+ 8 - 8
tcp_main.c

@@ -414,7 +414,6 @@ struct tcp_connection* tcpconn_new(int sock, union sockaddr_union* su,
 	c->rcv.proto_reserved2=0;
 	c->state=state;
 	c->extra_data=0;
-	c->flags|=F_CONN_REMOVED;
 #ifdef USE_TLS
 	if (type==PROTO_TLS){
 		if (tls_tcpconn_init(c, sock)==-1) goto error;
@@ -423,11 +422,10 @@ struct tcp_connection* tcpconn_new(int sock, union sockaddr_union* su,
 	{
 		c->type=PROTO_TCP;
 		c->rcv.proto=PROTO_TCP;
-		c->flags=0;
 		c->timeout=get_ticks()+tcp_con_lifetime;
 	}
-			
-		
+	c->flags|=F_CONN_REMOVED;
+	
 	tcp_connections_no++;
 	return c;
 	
@@ -1014,8 +1012,8 @@ static inline int handle_new_connect(struct socket_info* si)
 		tcpconn->refcnt++; /* safe, not yet available to the
 							  outside world */
 		tcpconn_add(tcpconn);
-		DBG("handle_new_connect: new connection: %p %d\n",
-			tcpconn, tcpconn->s);
+		DBG("handle_new_connect: new connection: %p %d flags: %04x\n",
+			tcpconn, tcpconn->s, tcpconn->flags);
 		/* pass it to a child */
 		if(send2child(tcpconn)<0){
 			LOG(L_ERR,"ERROR: handle_new_connect: no children "
@@ -1047,7 +1045,8 @@ static void tcpconn_destroy(struct tcp_connection* tcpconn)
 	TCPCONN_LOCK; /*avoid races w/ tcp_send*/
 	tcpconn->refcnt--;
 	if (tcpconn->refcnt==0){ 
-		DBG("tcpconn_destroy: destroying connection\n");
+		DBG("tcpconn_destroy: destroying connection %p, flags %04x\n",
+				tcpconn, tcpconn->flags);
 		fd=tcpconn->s;
 #ifdef USE_TLS
 		/*FIXME: lock ->writelock ? */
@@ -1061,7 +1060,8 @@ static void tcpconn_destroy(struct tcp_connection* tcpconn)
 		/* force timeout */
 		tcpconn->timeout=0;
 		tcpconn->state=S_CONN_BAD;
-		DBG("tcpconn_destroy: delaying ...\n");
+		DBG("tcpconn_destroy: delaying (%p, flags %04x) ...\n",
+				tcpconn, tcpconn->flags);
 		
 	}
 	TCPCONN_UNLOCK;