All of lore.kernel.org
 help / color / mirror / Atom feed
From: NeilBrown <neilb@cse.unsw.edu.au>
To: Marcelo Tosatti <marcelo.tosatti@cyclades.com.br>
Cc: nfs@lists.sourceforge.net
Subject: [PATCH] kNFSd - 4 of 6 - Make sure nfs/tcp socket only gets closed once.
Date: Thu, 04 Sep 2003 16:25:55 +1000	[thread overview]
Message-ID: <E19unZ5-0004VM-00@notabene> (raw)


It is possible for svc_delete_socket to be called multiple times,
which can cause problems.  This patch uses SK_DEAD to make sure it
only has any effect the first time, and uses SK_DEAD in a few other
places to make sure nothing is done on a deleted socket.

diff ./net/sunrpc/svcsock.c~current~ ./net/sunrpc/svcsock.c
--- ./net/sunrpc/svcsock.c~current~	2003-09-04 11:32:12.000000000 +1000
+++ ./net/sunrpc/svcsock.c	2003-09-04 11:45:48.000000000 +1000
@@ -120,6 +120,8 @@ svc_sock_enqueue(struct svc_sock *svsk)
 	if (!(svsk->sk_flags &
 	      ( (1<<SK_CONN)|(1<<SK_DATA)|(1<<SK_CLOSE)) ))
 		return;
+	if (test_bit(SK_DEAD, &svsk->sk_flags))
+		return;
 
 	spin_lock_bh(&serv->sv_lock);
 
@@ -930,6 +932,9 @@ svc_tcp_sendto(struct svc_rqst *rqstp)
 	bufp->iov[0].iov_len  = bufp->len << 2;
 	bufp->base[0] = htonl(0x80000000|((bufp->len << 2) - 4));
 
+	if (test_bit(SK_DEAD, &rqstp->rq_sock->sk_flags))
+		return -ENOTCONN;
+
 	sent = svc_sendto(rqstp, bufp->iov, bufp->nriov);
 	if (sent != bufp->len<<2) {
 		printk(KERN_NOTICE "rpc-srv/tcp: %s: sent only %d bytes of %d - shutting down socket\n",
@@ -1277,6 +1282,9 @@ svc_delete_socket(struct svc_sock *svsk)
 
 	dprintk("svc: svc_delete_socket(%p)\n", svsk);
 
+	if (test_and_set_bit(SK_DEAD, &svsk->sk_flags))
+		return ;
+
 	serv = svsk->sk_server;
 	sk = svsk->sk_sk;
 
@@ -1293,8 +1301,6 @@ svc_delete_socket(struct svc_sock *svsk)
 		list_del(&svsk->sk_ready);
 
 
-	set_bit(SK_DEAD, &svsk->sk_flags);
-
 	if (!svsk->sk_inuse) {
 		spin_unlock_bh(&serv->sv_lock);
 		sock_release(svsk->sk_sock);


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
NFS maillist  -  NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs

             reply	other threads:[~2003-09-04  6:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-04  6:25 NeilBrown [this message]
2003-09-04 12:53 ` [PATCH] kNFSd - 4 of 6 - Make sure nfs/tcp socket only gets closed once Marcelo Tosatti
2003-09-04 18:53   ` Marcelo Tosatti

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E19unZ5-0004VM-00@notabene \
    --to=neilb@cse.unsw.edu.au \
    --cc=marcelo.tosatti@cyclades.com.br \
    --cc=nfs@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.