diff mbox

[5/8] libceph: verify state after retaking con lock after dispatch

Message ID 1343663971-3221-6-git-send-email-sage@inktank.com (mailing list archive)
State New, archived
Headers show

Commit Message

Sage Weil July 30, 2012, 3:59 p.m. UTC
We drop the con mutex when delivering a message.  When we retake the
lock, we need to verify we are still in the OPEN state before
preparing to read the next tag, or else we risk stepping on a
connection that has been closed.

Signed-off-by: Sage Weil <sage@inktank.com>
---
 net/ceph/messenger.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Alex Elder July 31, 2012, 12:11 a.m. UTC | #1
On 07/30/2012 10:59 AM, Sage Weil wrote:
> We drop the con mutex when delivering a message.  When we retake the
> lock, we need to verify we are still in the OPEN state before
> preparing to read the next tag, or else we risk stepping on a
> connection that has been closed.
> 
> Signed-off-by: Sage Weil <sage@inktank.com>

Looks good.  And good to move the prepare_read_tag() out too.

Reviewed-by: Alex Elder <elder@inktank.com>

> ---
>  net/ceph/messenger.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
> index a6a0c7a..feb5a2a 100644
> --- a/net/ceph/messenger.c
> +++ b/net/ceph/messenger.c
> @@ -2003,7 +2003,6 @@ static void process_message(struct ceph_connection *con)
>  	con->ops->dispatch(con, msg);
>  
>  	mutex_lock(&con->mutex);
> -	prepare_read_tag(con);
>  }
>  
>  
> @@ -2213,6 +2212,8 @@ more:
>  		if (con->in_tag == CEPH_MSGR_TAG_READY)
>  			goto more;
>  		process_message(con);
> +		if (con->state == CON_STATE_OPEN)
> +			prepare_read_tag(con);
>  		goto more;
>  	}
>  	if (con->in_tag == CEPH_MSGR_TAG_ACK) {
> 

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index a6a0c7a..feb5a2a 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -2003,7 +2003,6 @@  static void process_message(struct ceph_connection *con)
 	con->ops->dispatch(con, msg);
 
 	mutex_lock(&con->mutex);
-	prepare_read_tag(con);
 }
 
 
@@ -2213,6 +2212,8 @@  more:
 		if (con->in_tag == CEPH_MSGR_TAG_READY)
 			goto more;
 		process_message(con);
+		if (con->state == CON_STATE_OPEN)
+			prepare_read_tag(con);
 		goto more;
 	}
 	if (con->in_tag == CEPH_MSGR_TAG_ACK) {