Skip to contentSkip to conversation

tcp: remove redundant SOCK_DONE checks

PATCH Applied Eric Dumazet 2 participants 2 messages Jul 8, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tcp: remove redundant SOCK_DONE checks

In both tcp_splice_read() and tcp_recvmsg(), we already test sock_flag(sk, SOCK_DONE) right before evaluating sk->sk_state, so "!sock_flag(sk, SOCK_DONE)" is always true.

---
 net/ipv4/tcp.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
net/ipv4/tcp.c +5 -9
index 850dc8f15afc4be53f550752b412f842f723a1af..c4082cd50257d2478e547bbe6538975acd1ac92d 100644
@@ -817,8 +817,7 @@ ssize_t tcp_splice_read(struct socket *sock, loff_t *ppos,
 				 * This occurs when user tries to read
 				 * from never connected socket.
 				 */
-				if (!sock_flag(sk, SOCK_DONE))
-					ret = -ENOTCONN;
+				ret = -ENOTCONN;
 				break;
 			}
 			if (!timeo) {
@@ -2042,13 +2041,10 @@ int tcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonblock,
 				break;
 
 			if (sk->sk_state == TCP_CLOSE) {
-				if (!sock_flag(sk, SOCK_DONE)) {
-					/* This occurs when user tries to read
-					 * from never connected socket.
-					 */
-					copied = -ENOTCONN;
-					break;
-				}
+				/* This occurs when user tries to read
+				 * from never connected socket.
+				 */
+				copied = -ENOTCONN;
 				break;
 			}
 
Signature · 1 line
2.18.0.203.gfac676dfb9-goog
maintainer Applied
#1 lore raw

From: Eric Dumazet <[email protected]>
Date: Sat, 7 Jul 2018 23:15:56 -0700

Quoted 5 lines

In both tcp_splice_read() and tcp_recvmsg(), we already test sock_flag(sk, SOCK_DONE) right before evaluating sk->sk_state, so "!sock_flag(sk, SOCK_DONE)" is always true.

Wow, I think this code has been like this since the initial GIT import.

Applied, thanks.