Browse code

- got the last tcp bug (hopefully :-))

Andrei Pelinescu-Onciul authored on 25/08/2003 13:11:24
Showing 3 changed files
... ...
@@ -40,7 +40,7 @@ export makefile_defs
40 40
 VERSION = 0
41 41
 PATCHLEVEL = 8
42 42
 SUBLEVEL =   11
43
-EXTRAVERSION = rc4
43
+EXTRAVERSION = rc5
44 44
 
45 45
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
46 46
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")
... ...
@@ -99,7 +99,7 @@ struct tcp_connection{
99 99
 #endif
100 100
 	struct tcp_req req; /* request data */
101 101
 	volatile int refcnt;
102
-	int state; /* connection state, only EOF and OK for now */
102
+	enum tcp_conn_states state;/* connection state, only EOF and OK for now */
103 103
 	int bad; /* if set this is a "bad" connection */
104 104
 	int timeout; /* connection timeout, after this it will be removed*/
105 105
 	unsigned addr_hash; /* hash indexes in the 2 tables */
... ...
@@ -455,11 +455,13 @@ send_it:
455 455
 		response[0]=(long)c;
456 456
 		response[1]=CONN_ERROR;
457 457
 		n=write(unix_tcp_sock, response, sizeof(response));
458
+		/* CONN_ERROR wil auto-dec refcnt => we must not call tcpconn_put !!*/
458 459
 		if (n<0){
459
-			LOG(L_ERR, "BUG: tcp_send: failed to get fd(write):%s (%d)\n",
460
+			LOG(L_ERR, "BUG: tcp_send: error return failed (write):%s (%d)\n",
460 461
 					strerror(errno), errno);
461
-			goto release_c;
462 462
 		}
463
+		close(fd);
464
+		return n; /* error return, no tcpconn_put */
463 465
 	}
464 466
 end:
465 467
 	close(fd);
... ...
@@ -753,12 +755,14 @@ read_again:
753 755
 					/* don't listen on it any more */
754 756
 					FD_CLR(pt[r].unix_sock, &master_set);
755 757
 					/*exit(-1)*/;
758
+					continue;
756 759
 				}else if (bytes<0){
757 760
 					if (errno==EINTR) goto read_again;
758 761
 					else{
759 762
 						LOG(L_CRIT, "ERROR: tcp_main_loop: read from child: "
760 763
 								" %s\n", strerror(errno));
761 764
 						/* try to continue ? */
765
+						continue;
762 766
 					}
763 767
 				}
764 768
 					
... ...
@@ -787,6 +791,7 @@ read_again:
787 791
 					case CONN_ERROR:
788 792
 					case CONN_DESTROY:
789 793
 					case CONN_EOF:
794
+						/* WARNING: this will auto-dec. refcnt! */
790 795
 						if (pt[r].idx>=0){
791 796
 							tcp_children[pt[r].idx].busy--;
792 797
 						}else{