patch-2.3.15 linux/net/khttpd/datasending.c

Next file: linux/net/khttpd/main.c
Previous file: linux/net/khttpd/accept.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.14/linux/net/khttpd/datasending.c linux/net/khttpd/datasending.c
@@ -34,6 +34,7 @@
 	The number of requests that changed status (ie: made some progress)
 */
 
+#include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/skbuff.h>
 
@@ -69,11 +70,9 @@
 		  
 		
 		Space=4096;
-		if (CurrentRequest->sock->sk!=NULL)
+		if (CurrentRequest->sock->sk!=NULL) /* It's impossible */
 		{
-			lock_sock(CurrentRequest->sock->sk);
 			Space = sock_wspace(CurrentRequest->sock->sk);
-			release_sock(CurrentRequest->sock->sk);
 		}
 		
 		ReadSize = min(4096,CurrentRequest->FileLength - CurrentRequest->BytesSent);
@@ -84,6 +83,8 @@
 			/* This part does a redundant data-copy. To bad for now. 
 			   In the future, we might want to nick the data right out
 			   of the page-cache
+
+			   WHY DO YOU NOT USE SENDFILE?
 			*/
 		
 			CurrentRequest->filp->f_pos = CurrentRequest->BytesSent;
@@ -104,30 +105,27 @@
 			}
 		
 		}
-		lock_sock(CurrentRequest->sock->sk);
 		
 		/* 
 		   If end-of-file or closed connection: Finish this request 
 		   by moving it to the "logging" queue. 
 		*/
 		if ((CurrentRequest->BytesSent>=CurrentRequest->FileLength)||
-		   (CurrentRequest->sock->sk->state !=TCP_ESTABLISHED))
+		    (CurrentRequest->sock->sk->state!=TCP_ESTABLISHED
+		     && CurrentRequest->sock->sk->state!=TCP_CLOSE_WAIT))
 		{
 			struct http_request *Next;
 			Next = CurrentRequest->Next;
-						
-			if  (CurrentRequest->sock->sk->state ==TCP_ESTABLISHED)
+
+			lock_sock(CurrentRequest->sock->sk);
+			if  (CurrentRequest->sock->sk->state == TCP_ESTABLISHED ||
+			     CurrentRequest->sock->sk->state == TCP_CLOSE_WAIT)
 			{
-			
 				CurrentRequest->sock->sk->nonagle = 0;
-				CurrentRequest->sock->sk->linger = 0;
 				tcp_push_pending_frames(CurrentRequest->sock->sk,&(CurrentRequest->sock->sk->tp_pinfo.af_tcp));
 			}
-			
 			release_sock(CurrentRequest->sock->sk);
 
-
-
 			(*Prev) = CurrentRequest->Next;
 			
 			CurrentRequest->Next = threadinfo[CPUNR].LoggingQueue;
@@ -137,7 +135,6 @@
 			continue;
 		
 		}
-		release_sock(CurrentRequest->sock->sk);
 		
 
 		Prev = &(CurrentRequest->Next);	

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)