aboutsummaryrefslogtreecommitdiffstats
path: root/net/ceph
diff options
context:
space:
mode:
authorSage Weil <sage@inktank.com>2012-07-20 18:34:04 -0400
committerSage Weil <sage@inktank.com>2012-07-30 21:15:57 -0400
commita59b55a602b6c741052d79c1e3643f8440cddd27 (patch)
tree4ffe59cd04d00fe0835256065b5b08a7c5505d1b /net/ceph
parent00650931e52e97fe64096bec167f5a6780dfd94a (diff)
libceph: move ceph_con_send() closed check under the con mutex
Take the con mutex before checking whether the connection is closed to avoid racing with someone else closing it. Signed-off-by: Sage Weil <sage@inktank.com>
Diffstat (limited to 'net/ceph')
-rw-r--r--net/ceph/messenger.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 1a3cb4a4f180..20e60a80bc29 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -2453,22 +2453,20 @@ static void clear_standby(struct ceph_connection *con)
2453 */ 2453 */
2454void ceph_con_send(struct ceph_connection *con, struct ceph_msg *msg) 2454void ceph_con_send(struct ceph_connection *con, struct ceph_msg *msg)
2455{ 2455{
2456 if (test_bit(CLOSED, &con->state)) {
2457 dout("con_send %p closed, dropping %p\n", con, msg);
2458 ceph_msg_put(msg);
2459 return;
2460 }
2461
2462 /* set src+dst */ 2456 /* set src+dst */
2463 msg->hdr.src = con->msgr->inst.name; 2457 msg->hdr.src = con->msgr->inst.name;
2464
2465 BUG_ON(msg->front.iov_len != le32_to_cpu(msg->hdr.front_len)); 2458 BUG_ON(msg->front.iov_len != le32_to_cpu(msg->hdr.front_len));
2466
2467 msg->needs_out_seq = true; 2459 msg->needs_out_seq = true;
2468 2460
2469 /* queue */
2470 mutex_lock(&con->mutex); 2461 mutex_lock(&con->mutex);
2471 2462
2463 if (test_bit(CLOSED, &con->state)) {
2464 dout("con_send %p closed, dropping %p\n", con, msg);
2465 ceph_msg_put(msg);
2466 mutex_unlock(&con->mutex);
2467 return;
2468 }
2469
2472 BUG_ON(msg->con != NULL); 2470 BUG_ON(msg->con != NULL);
2473 msg->con = con->ops->get(con); 2471 msg->con = con->ops->get(con);
2474 BUG_ON(msg->con == NULL); 2472 BUG_ON(msg->con == NULL);