Commit 69b6ba3712b796a66595cfaf0a5ab4dfe1cf964a
Committed by
J. Bruce Fields
1 parent
262a09823b
Exists in
master
and in
7 other branches
SUNRPC: Ensure the server closes sockets in a timely fashion
We want to ensure that connected sockets close down the connection when we set XPT_CLOSE, so that we don't keep it hanging while cleaning up all the stuff that is keeping a reference to the socket. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com> Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Showing 1 changed file with 20 additions and 1 deletions Side-by-side Diff
net/sunrpc/svcsock.c
... | ... | @@ -59,6 +59,7 @@ |
59 | 59 | static int svc_udp_recvfrom(struct svc_rqst *); |
60 | 60 | static int svc_udp_sendto(struct svc_rqst *); |
61 | 61 | static void svc_sock_detach(struct svc_xprt *); |
62 | +static void svc_tcp_sock_detach(struct svc_xprt *); | |
62 | 63 | static void svc_sock_free(struct svc_xprt *); |
63 | 64 | |
64 | 65 | static struct svc_xprt *svc_create_socket(struct svc_serv *, int, |
... | ... | @@ -1017,7 +1018,7 @@ |
1017 | 1018 | .xpo_recvfrom = svc_tcp_recvfrom, |
1018 | 1019 | .xpo_sendto = svc_tcp_sendto, |
1019 | 1020 | .xpo_release_rqst = svc_release_skb, |
1020 | - .xpo_detach = svc_sock_detach, | |
1021 | + .xpo_detach = svc_tcp_sock_detach, | |
1021 | 1022 | .xpo_free = svc_sock_free, |
1022 | 1023 | .xpo_prep_reply_hdr = svc_tcp_prep_reply_hdr, |
1023 | 1024 | .xpo_has_wspace = svc_tcp_has_wspace, |
... | ... | @@ -1287,6 +1288,24 @@ |
1287 | 1288 | sk->sk_state_change = svsk->sk_ostate; |
1288 | 1289 | sk->sk_data_ready = svsk->sk_odata; |
1289 | 1290 | sk->sk_write_space = svsk->sk_owspace; |
1291 | + | |
1292 | + if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) | |
1293 | + wake_up_interruptible(sk->sk_sleep); | |
1294 | +} | |
1295 | + | |
1296 | +/* | |
1297 | + * Disconnect the socket, and reset the callbacks | |
1298 | + */ | |
1299 | +static void svc_tcp_sock_detach(struct svc_xprt *xprt) | |
1300 | +{ | |
1301 | + struct svc_sock *svsk = container_of(xprt, struct svc_sock, sk_xprt); | |
1302 | + | |
1303 | + dprintk("svc: svc_tcp_sock_detach(%p)\n", svsk); | |
1304 | + | |
1305 | + svc_sock_detach(xprt); | |
1306 | + | |
1307 | + if (!test_bit(XPT_LISTENER, &xprt->xpt_flags)) | |
1308 | + kernel_sock_shutdown(svsk->sk_sock, SHUT_RDWR); | |
1290 | 1309 | } |
1291 | 1310 | |
1292 | 1311 | /* |