patch-2.0.15 linux/net/ipv4/tcp.c

Next file: linux/Makefile
Previous file: linux/net/ipv4/ip_fw.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.0.14/linux/net/ipv4/tcp.c linux/net/ipv4/tcp.c
@@ -867,15 +867,24 @@
 static void wait_for_tcp_memory(struct sock * sk)
 {
 	release_sock(sk);
-	cli();
-	if (!tcp_memory_free(sk) &&
-	    (sk->state == TCP_ESTABLISHED||sk->state == TCP_CLOSE_WAIT)
-		&& sk->err == 0 /* && check shutdown ?? */)
-	{
+	if (!tcp_memory_free(sk)) {
+		struct wait_queue wait = { current, NULL };
+
 		sk->socket->flags &= ~SO_NOSPACE;
-		interruptible_sleep_on(sk->sleep);
+		add_wait_queue(sk->sleep, &wait);
+		for (;;) {
+			current->state = TASK_INTERRUPTIBLE;
+			if (tcp_memory_free(sk))
+				break;
+			if (sk->shutdown & SEND_SHUTDOWN)
+				break;
+			if (sk->err)
+				break;
+			schedule();
+		}
+		current->state = TASK_RUNNING;
+		remove_wait_queue(sk->sleep, &wait);
 	}
-	sti();
 	lock_sock(sk);
 }
 


FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov