kNFSd - 3 of 8 - Make sure an early close on a nfs/tcp connection is handled properly.
Subsystems (3)
PATCH 1/1 kNFSd - 3 of 8 - Make sure an early close on a nfs/tcp connection is handled properly.
### Comments for ChangeSet
From: Hirokazu Takahashi <[email protected]>
In svc_tcp_listen_data_ready we should be waiting for TCP_LISTEN, not TCP_ESTABLISHED. The later only worked by accident.
Also, if a socket is closed as soon as we accept it, we must shut it down straight away as we will never get a 'close' event.
----------- Diffstat output ------------
./net/sunrpc/svcsock.c | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-)
net/sunrpc/svcsock.c renamed from net/sunrpc/svcsock.c~current~ +13 -2
@@ -681,8 +681,17 @@ svc_tcp_listen_data_ready(struct sock *sdprintk ("svc: socket %p TCP (listen) state change %d\n" , sk, sk->sk_state); -if (sk->sk_state !=TCP_ESTABLISHED ) { -/* Aborted connection, SYN_RECV or whatever... */ +if (sk->sk_state !=TCP_LISTEN ) { +/* +* This callback may called twice when a new connection +* is established as a child socket inherits everything +* from a parent LISTEN socket. +* 1) data_ready method of the parent socket will be called +* when one of child sockets become ESTABLISHED. +* 2) data_ready method of the child socket may be called +* when it receives data before the socket is accepted. +* In case of 2, we should ignore it silently. +*/ goto out; }if (!(svsk = (struct svc_sock *) sk->sk_user_data)) {
@@ -1060,6 +1069,8 @@ svc_tcp_init(struct svc_sock *svsk)set_bit (SK_CHNGBUF , &svsk->sk_flags);set_bit (SK_DATA , &svsk->sk_flags); +if (sk->sk_state !=TCP_ESTABLISHED ) +set_bit (SK_CLOSE , &svsk->sk_flags); } }
-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner. Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission! INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs