All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Elder <elder@inktank.com>
To: "ceph-devel@vger.kernel.org" <ceph-devel@vger.kernel.org>
Subject: [PATCH 2/2] libceph: close socket directly during ceph_con_close()
Date: Tue, 26 Jun 2012 14:46:47 -0700	[thread overview]
Message-ID: <4FEA2DC7.1080104@inktank.com> (raw)
In-Reply-To: <4FEA2D76.8080907@inktank.com>

When we close the connection, immediately shut down the socket
instead of queuing work and letting the worker thread do it.  This
is simpler.

Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Alex Elder <elder@inktank.com>
---
  net/ceph/messenger.c |   29 +++++++++++++++--------------
  1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index fe42a36..2f574d2 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -47,18 +47,18 @@
   *       |       \ con_sock_state_connecting()
   *       |        ----------------------
   *       |                              \
- *       + con_sock_state_closed()       \
- *       |\                               \
- *       | \                               \
- *       |  -----------                     \
- *       |  | CLOSING |  socket event;       \
- *       |  -----------  await close          \
- *       |       ^                            |
- *       |       |                            |
- *       |       + con_sock_state_closing()   |
- *       |      / \                           |
- *       |     /   ---------------            |
- *       |    /                   \           v
+ *       +---------------------------    \
+ *       |\ con_sock_state_closed()  \    \
+ *       | \                          \    \
+ *       |  -----------                \    \
+ *       |  | CLOSING |  socket event;  \    \
+ *       |  -----------  await close     \    \
+ *       |       ^                        \   |
+ *       |       |                         \  |
+ *       |       + con_sock_state_closing() \ |
+ *       |      / \                         | |
+ *       |     /   ---------------          | |
+ *       |    /                   \         | v
   *       |   /                    --------------
   *       |  /    -----------------| CONNECTING |  socket created, TCP
   *       |  |   /                 --------------  connect initiated
@@ -241,7 +241,8 @@ static void con_sock_state_closed(struct 
ceph_connection *con)

  	old_state = atomic_xchg(&con->sock_state, CON_SOCK_STATE_CLOSED);
  	if (WARN_ON(old_state != CON_SOCK_STATE_CONNECTED &&
-			old_state != CON_SOCK_STATE_CLOSING))
+		    old_state != CON_SOCK_STATE_CLOSING &&
+		    old_state != CON_SOCK_STATE_CONNECTING))
  		printk("%s: unexpected old state %d\n", __func__, old_state);
  }

@@ -514,9 +515,9 @@ void ceph_con_close(struct ceph_connection *con)
  	mutex_lock(&con->mutex);
  	reset_connection(con);
  	con->peer_global_seq = 0;
+	con_close_socket(con);
  	cancel_delayed_work(&con->work);
  	mutex_unlock(&con->mutex);
-	queue_con(con);
  }
  EXPORT_SYMBOL(ceph_con_close);

-- 
1.7.9.5


      parent reply	other threads:[~2012-06-26 21:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-26 21:45 [PATCH 0/2] libceph fixes Alex Elder
2012-06-26 21:46 ` [PATCH 1/2] libceph: set peer name on con_open, not init Alex Elder
2012-06-26 21:46 ` Alex Elder [this message]

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=4FEA2DC7.1080104@inktank.com \
    --to=elder@inktank.com \
    --cc=ceph-devel@vger.kernel.org \
    /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.