From: Geliang Tang <tanggeliang@kylinos.cn>
Use the newly added tcp_recv_should_stop() helper in mptcp_recvmsg() to
check whether to stop receiving.
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
net/mptcp/protocol.c | 32 ++++++--------------------------
1 file changed, 6 insertions(+), 26 deletions(-)
diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index f55185410e5b..6574f82d59d1 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -2183,20 +2183,12 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
if (copied >= target)
break;
- if (copied) {
- if (sk->sk_err ||
- sk->sk_state == TCP_CLOSE ||
- (sk->sk_shutdown & RCV_SHUTDOWN) ||
- !timeo ||
- signal_pending(current))
- break;
- } else {
- if (sk->sk_err) {
- copied = sock_error(sk);
+ err = tcp_recv_should_stop(sk, timeo);
+ if (err < 0) {
+ if (copied)
break;
- }
- if (sk->sk_shutdown & RCV_SHUTDOWN) {
+ if (err == -ESHUTDOWN) {
/* race breaker: the shutdown could be after the
* previous receive queue check
*/
@@ -2205,20 +2197,8 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
break;
}
- if (sk->sk_state == TCP_CLOSE) {
- copied = -ENOTCONN;
- break;
- }
-
- if (!timeo) {
- copied = -EAGAIN;
- break;
- }
-
- if (signal_pending(current)) {
- copied = sock_intr_errno(timeo);
- break;
- }
+ copied = err;
+ break;
}
pr_debug("block timeout %ld\n", timeo);
--
2.48.1