Browse code

- more debuging info for tcp cleanups - cosmetic changes

Andrei Pelinescu-Onciul authored on 04/07/2003 20:12:05
Showing 2 changed files
... ...
@@ -282,7 +282,7 @@ void _tcpconn_rm(struct tcp_connection* c)
282 282
 	tcpconn_listrm(tcpconn_id_hash[c->id_hash], c, id_next, id_prev);
283 283
 	lock_destroy(&c->write_lock);
284 284
 #ifdef USE_TLS
285
-	if ((c->type==PROTO_TLS)&&(c->extra_data)) tls_tcpconn_clean(c);
285
+	if (c->type==PROTO_TLS) tls_tcpconn_clean(c);
286 286
 #endif
287 287
 	shm_free(c);
288 288
 }
... ...
@@ -505,7 +505,8 @@ void tcpconn_timeout(fd_set* set)
505 505
 {
506 506
 	struct tcp_connection *c, *next;
507 507
 	int ticks;
508
-	unsigned h;;
508
+	unsigned h;
509
+	int fd;
509 510
 	
510 511
 	
511 512
 	ticks=get_ticks();
... ...
@@ -517,11 +518,12 @@ void tcpconn_timeout(fd_set* set)
517 517
 			if ((c->refcnt==0) && (ticks>c->timeout)) {
518 518
 				DBG("tcpconn_timeout: timeout for hash=%d - %p (%d > %d)\n",
519 519
 						h, c, ticks, c->timeout);
520
-				if (c->s>0) {
521
-					FD_CLR(c->s, set);
522
-					close(c->s);
523
-				}
520
+				fd=c->s;
524 521
 				_tcpconn_rm(c);
522
+				if (fd>0) {
523
+					FD_CLR(fd, set);
524
+					close(fd);
525
+				}
525 526
 			}
526 527
 			c=next;
527 528
 		}
... ...
@@ -717,6 +719,7 @@ void tcp_main_loop()
717 717
 	int cmd;
718 718
 	int bytes;
719 719
 	struct timeval timeout;
720
+	int fd;
720 721
 
721 722
 	/*init */
722 723
 	maxfd=0;
... ...
@@ -783,8 +786,9 @@ void tcp_main_loop()
783 783
 									"children available\n");
784 784
 						TCPCONN_LOCK;
785 785
 						if (tcpconn->refcnt==0){
786
-							close(tcpconn->s);
786
+							fd=tcpconn->s;
787 787
 							_tcpconn_rm(tcpconn);
788
+							close(fd);
788 789
 						}else tcpconn->timeout=0; /* force expire*/
789 790
 						TCPCONN_UNLOCK;
790 791
 					}
... ...
@@ -855,8 +859,9 @@ read_again:
855 855
 							tcpconn->refcnt--;
856 856
 							if (tcpconn->refcnt==0){ 
857 857
 								DBG("tcp_main_loop: destroying connection\n");
858
-								close(tcpconn->s);
858
+								fd=tcpconn->s;
859 859
 								_tcpconn_rm(tcpconn);
860
+								close(fd);
860 861
 							}else{
861 862
 								/* force timeout */
862 863
 								tcpconn->timeout=0;
... ...
@@ -529,6 +529,7 @@ again:
529 529
 		
530 530
 		
531 531
 	end_req:
532
+		
532 533
 		return resp;
533 534
 }
534 535
 
... ...
@@ -540,6 +541,7 @@ void release_tcpconn(struct tcp_connection* c, long state, int unix_sock)
540 540
 	
541 541
 		DBG( "releasing con %p, state %ld, fd=%d, id=%d\n",
542 542
 				c, state, c->fd, c->id);
543
+		DBG(" extra_data %p\n", c->extra_data);
543 544
 		/* release req & signal the parent */
544 545
 		if (c->fd!=-1) close(c->fd);
545 546
 		/* errno==EINTR, EWOULDBLOCK a.s.o todo */