Commit 5d0f354b authored by Sage Weil's avatar Sage Weil Committed by Greg Kroah-Hartman

libceph: move ceph_con_send() closed check under the con mutex

(cherry picked from commit a59b55a6)

Take the con mutex before checking whether the connection is closed to
avoid racing with someone else closing it.
Signed-off-by: default avatarSage Weil <sage@inktank.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 67c6fc19
...@@ -2453,22 +2453,20 @@ static void clear_standby(struct ceph_connection *con) ...@@ -2453,22 +2453,20 @@ static void clear_standby(struct ceph_connection *con)
*/ */
void ceph_con_send(struct ceph_connection *con, struct ceph_msg *msg) void ceph_con_send(struct ceph_connection *con, struct ceph_msg *msg)
{ {
if (test_bit(CLOSED, &con->state)) {
dout("con_send %p closed, dropping %p\n", con, msg);
ceph_msg_put(msg);
return;
}
/* set src+dst */ /* set src+dst */
msg->hdr.src = con->msgr->inst.name; msg->hdr.src = con->msgr->inst.name;
BUG_ON(msg->front.iov_len != le32_to_cpu(msg->hdr.front_len)); BUG_ON(msg->front.iov_len != le32_to_cpu(msg->hdr.front_len));
msg->needs_out_seq = true; msg->needs_out_seq = true;
/* queue */
mutex_lock(&con->mutex); mutex_lock(&con->mutex);
if (test_bit(CLOSED, &con->state)) {
dout("con_send %p closed, dropping %p\n", con, msg);
ceph_msg_put(msg);
mutex_unlock(&con->mutex);
return;
}
BUG_ON(msg->con != NULL); BUG_ON(msg->con != NULL);
msg->con = con->ops->get(con); msg->con = con->ops->get(con);
BUG_ON(msg->con == NULL); BUG_ON(msg->con == NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment