Browse code

- tcp read bug fixes (semi-minor, backported from HEAD)

Andrei Pelinescu-Onciul authored on 09/07/2003 16:38:20
Showing 2 changed files
... ...
@@ -40,7 +40,7 @@ export makefile_defs
40 40
 VERSION = 0
41 41
 PATCHLEVEL = 8
42 42
 SUBLEVEL =   11
43
-EXTRAVERSION = pre39
43
+EXTRAVERSION = pre40
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]")
... ...
@@ -31,6 +31,7 @@
31 31
  * 2003-02-10  zero term before calling receive_msg & undo afterwards (andrei)
32 32
  * 2003-05-13  l: (short form of Content-Length) is now recognized (andrei)
33 33
  * 2003-07-04  fixed eof for tcp_read_req  (andrei)
34
+ * 2003-07-09  fix a possible bug in tcp_receive_loop (andrei)
34 35
  */
35 36
 
36 37
 #ifdef USE_TCP
... ...
@@ -550,37 +551,37 @@ void tcp_receive_loop(int unix_sock)
550 551
 				if (n<0){
551 552
 					if (errno == EWOULDBLOCK || errno == EAGAIN ||
552 553
 							errno == EINTR){
553
-						continue;
554
+						goto skip;
554 555
 					}else{
555 556
 						LOG(L_CRIT,"BUG: tcp_receive_loop: read_fd: %s\n",
556 557
 							strerror(errno));
557 558
 						abort(); /* big error*/
558 559
 					}
559 560
 				}
561
+				DBG("received n=%d con=%p, fd=%d\n", n, con, s);
560 562
 				if (n==0){
561 563
 					LOG(L_ERR, "WARNING: tcp_receive_loop: 0 bytes read\n");
562
-					continue;
564
+					goto skip;
565
+				}
566
+				if (con==0){
567
+					LOG(L_CRIT, "BUG: tcp_receive_loop: null pointer\n");
568
+					goto skip;
563 569
 				}
564 570
 				con->fd=s;
565
-				DBG("received n=%d con=%p, fd=%d\n", n, con, s);
566 571
 				if (s==-1) {
567 572
 					LOG(L_ERR, "ERROR: tcp_receive_loop: read_fd:"
568 573
 									"no fd read\n");
569 574
 					resp=CONN_ERROR;
570 575
 					con->bad=1;
571 576
 					release_tcpconn(con, resp, unix_sock);
572
-				}
573
-				if (con==0){
574
-					LOG(L_ERR, "ERROR: tcp_receive_loop: null pointer\n");
575
-					resp=CONN_ERROR;
576
-					con->bad=1;
577
-					release_tcpconn(con, resp, unix_sock);
577
+					goto skip;
578 578
 				}
579 579
 				con->timeout=get_ticks()+TCP_CHILD_TIMEOUT;
580 580
 				FD_SET(s, &master_set);
581 581
 				if (maxfd<s) maxfd=s;
582 582
 				tcpconn_listadd(list, con, c_next, c_prev);
583 583
 			}
584
+skip:
584 585
 			ticks=get_ticks();
585 586
 			for (con=list; con ; con=c_next){
586 587
 				c_next=con->c_next; /* safe for removing*/