net: Fix the condition passed to sk_wait_event()
Subsystems (2)
Dave,
Thinking more about it, we need to check for sk->sk_err, thus the
existing code behaves fine. Just that we might incur an additional sleep even while we know that the socket already has an error, but that should be ok.
We only need the other patch. Pls ignore this, and sorry for the confusion.
Thanks,
Tomar
Quoted 55 lines · Nagendra Tomar
From: Nagendra Tomar <[email protected]>
Subject: [PATCH 1/2] net: Fix the condition passed tosk_wait_event()
To: [email protected]
Cc: [email protected], [email protected]
Date: Sunday, 3 October, 2010, 5:19
This patch fixes thesk_wait_event()
condition in thesk_stream_wait_connect()
function. With this change, we correctly check for theTCPF_ESTABLISHEDandTCPF_CLOSE_WAITstates and avoid potentially returning success when there
might be an error on the socket.Signed-off-by: Nagendra Singh Tomar <tomer_iisc@xxxxxxxxx>
---
--- linux-2.6.35.7/net/core/stream.c.orig2010-03-24 09:30:00.000000000 +0530 +++ linux-2.6.35.7/net/core/stream.c 2010-03-24 09:30:17.000000000 +0530(quoted diff) +0
-1@@ -73,9 +73,8 @@ int sk_stream_wait_connect(struct sock * prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); sk->sk_write_pending++; done = sk_wait_event(sk, timeo_p, -!sk->sk_err
&&
-
!((1 <<sk->sk_state) &
-
~(TCPF_ESTABLISHED |TCPF_CLOSE_WAIT))); +
((1 <<sk->sk_state) &
+
(TCPF_ESTABLISHED |TCPF_CLOSE_WAIT)));finish_wait(sk_sleep(sk), &wait);
sk->sk_write_pending--;
} while (!done);---