Browse code

- fixed eof detection in tcp_read_req (specially crafted tcp connections could cause the tcp reader process to enter eat 100% cpu time, even when it should've slept)

Andrei Pelinescu-Onciul authored on 04/07/2003 14:25:14
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 = pre35
43
+EXTRAVERSION = pre36
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]")
... ...
@@ -30,6 +30,7 @@
30 30
  * 2002-12-??  created by andrei.
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
+ * 2003-07-04  fixed eof for tcp_read_req  (andrei)
33 34
  */
34 35
 
35 36
 #ifdef USE_TCP
... ...
@@ -375,9 +376,8 @@ int tcp_read_req(struct tcp_connection* con)
375 376
 		resp=CONN_RELEASE;
376 377
 		s=con->fd;
377 378
 		req=&con->req;
378
-		size=0;
379 379
 again:
380
-		if(req->complete==0 && req->error==TCP_REQ_OK){
380
+		if(req->error==TCP_REQ_OK){
381 381
 			bytes=tcp_read_headers(req, s);
382 382
 #ifdef EXTRA_DEBUG
383 383
 						/* if timeout state=0; goto end__req; */
... ...
@@ -393,7 +393,7 @@ again:
393 393
 				resp=CONN_ERROR;
394 394
 				goto end_req;
395 395
 			}
396
-			if ((size==0) && (bytes==0)){
396
+			if ((req->complete==0) && (bytes==0)){
397 397
 				DBG( "tcp_read_req: EOF\n");
398 398
 				resp=CONN_EOF;
399 399
 				goto end_req;
... ...
@@ -475,6 +475,7 @@ again:
475 475
 			req->bytes_to_go=0;
476 476
 			/* if we still have some unparsed bytes, try to  parse them too*/
477 477
 			if (size) goto again;
478
+			else if (bytes==0) resp=CONN_EOF;/* 0 bytes read, this is an EOF*/
478 479
 			
479 480
 		}
480 481