Skip to content

Commit

Permalink
tcp: check local var (timeo) before socket fields in one test
Browse files Browse the repository at this point in the history
Testing timeo before sk_err/sk_state/sk_shutdown makes more sense.

Modern applications use non-blocking IO, while a socket is terminated
only once during its life time.

Signed-off-by: Eric Dumazet <edumazet@google.com>
  • Loading branch information
Eric Dumazet authored and xanmod committed Jan 12, 2022
1 parent 8a307a7 commit 6c55b20
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions net/ipv4/tcp.c
Expand Up @@ -2403,10 +2403,10 @@ static int tcp_recvmsg_locked(struct sock *sk, struct msghdr *msg, size_t len,
break;

if (copied) {
if (sk->sk_err ||
if (!timeo ||
sk->sk_err ||
sk->sk_state == TCP_CLOSE ||
(sk->sk_shutdown & RCV_SHUTDOWN) ||
!timeo ||
signal_pending(current))
break;
} else {
Expand Down

0 comments on commit 6c55b20

Please sign in to comment.