Browse code

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

Andrei Pelinescu-Onciul authored on 17/11/2005 01:22:03
Showing 3 changed files
... ...
@@ -61,7 +61,7 @@ MAIN_NAME=ser
61 61
 VERSION = 0
62 62
 PATCHLEVEL = 10
63 63
 SUBLEVEL =   99
64
-EXTRAVERSION = -dev22-tcp
64
+EXTRAVERSION = -dev23-tcp
65 65
 
66 66
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
67 67
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")
... ...
@@ -126,14 +126,14 @@ struct tcp_connection{
126 126
 	int flags; /* connection related flags */
127 127
 	enum tcp_conn_states state; /* connection state */
128 128
 	void* extra_data; /* extra data associated to the connection, 0 for tcp*/
129
-	int timeout; /* connection timeout, after this it will be removed*/
129
+	unsigned int timeout;/* connection timeout, after this it will be removed*/
130 130
 	unsigned id_hash; /* hash index in the id_hash */
131
-	int aliases; /* aliases number, at least 1 */
132
-	struct tcp_conn_alias con_aliases[TCP_CON_MAX_ALIASES];
133 131
 	struct tcp_connection* id_next; /* next, prev in id hash table */
134 132
 	struct tcp_connection* id_prev;
135 133
 	struct tcp_connection* c_next; /* child next prev (use locally) */
136 134
 	struct tcp_connection* c_prev;
135
+	struct tcp_conn_alias con_aliases[TCP_CON_MAX_ALIASES];
136
+	int aliases; /* aliases number, at least 1 */
137 137
 };
138 138
 
139 139
 
... ...
@@ -414,7 +414,6 @@ struct tcp_connection* tcpconn_new(int sock, union sockaddr_union* su,
414 414
 	c->rcv.proto_reserved2=0;
415 415
 	c->state=state;
416 416
 	c->extra_data=0;
417
-	c->flags|=F_CONN_REMOVED;
418 417
 #ifdef USE_TLS
419 418
 	if (type==PROTO_TLS){
420 419
 		if (tls_tcpconn_init(c, sock)==-1) goto error;
... ...
@@ -423,11 +422,10 @@ struct tcp_connection* tcpconn_new(int sock, union sockaddr_union* su,
423 423
 	{
424 424
 		c->type=PROTO_TCP;
425 425
 		c->rcv.proto=PROTO_TCP;
426
-		c->flags=0;
427 426
 		c->timeout=get_ticks()+tcp_con_lifetime;
428 427
 	}
429
-			
430
-		
428
+	c->flags|=F_CONN_REMOVED;
429
+	
431 430
 	tcp_connections_no++;
432 431
 	return c;
433 432
 	
... ...
@@ -1014,8 +1012,8 @@ static inline int handle_new_connect(struct socket_info* si)
1014 1014
 		tcpconn->refcnt++; /* safe, not yet available to the
1015 1015
 							  outside world */
1016 1016
 		tcpconn_add(tcpconn);
1017
-		DBG("handle_new_connect: new connection: %p %d\n",
1018
-			tcpconn, tcpconn->s);
1017
+		DBG("handle_new_connect: new connection: %p %d flags: %04x\n",
1018
+			tcpconn, tcpconn->s, tcpconn->flags);
1019 1019
 		/* pass it to a child */
1020 1020
 		if(send2child(tcpconn)<0){
1021 1021
 			LOG(L_ERR,"ERROR: handle_new_connect: no children "
... ...
@@ -1047,7 +1045,8 @@ static void tcpconn_destroy(struct tcp_connection* tcpconn)
1047 1047
 	TCPCONN_LOCK; /*avoid races w/ tcp_send*/
1048 1048
 	tcpconn->refcnt--;
1049 1049
 	if (tcpconn->refcnt==0){ 
1050
-		DBG("tcpconn_destroy: destroying connection\n");
1050
+		DBG("tcpconn_destroy: destroying connection %p, flags %04x\n",
1051
+				tcpconn, tcpconn->flags);
1051 1052
 		fd=tcpconn->s;
1052 1053
 #ifdef USE_TLS
1053 1054
 		/*FIXME: lock ->writelock ? */
... ...
@@ -1061,7 +1060,8 @@ static void tcpconn_destroy(struct tcp_connection* tcpconn)
1061 1061
 		/* force timeout */
1062 1062
 		tcpconn->timeout=0;
1063 1063
 		tcpconn->state=S_CONN_BAD;
1064
-		DBG("tcpconn_destroy: delaying ...\n");
1064
+		DBG("tcpconn_destroy: delaying (%p, flags %04x) ...\n",
1065
+				tcpconn, tcpconn->flags);
1065 1066
 		
1066 1067
 	}
1067 1068
 	TCPCONN_UNLOCK;