@@ -1816,10 +1820,19 @@ static int try_read(struct ceph_connection *con)
dout("try_read start on %p state %lu\n", con, con->state);
more:
dout("try_read %p state %lu tag %d in_base_pos %d\n", con,
con->state, (int)con->in_tag, con->in_base_pos);
+
+ /* process_connect, process_message need to drop con->mutex,
+ * so connection state might have changed on us. Check it,
+ * leave if necessary so new state can be processed.
+ */
+ if (test_bit(CLOSED, &con->state) ||
+ test_bit(OPENING, &con->state))
+ goto out;
+
if (test_bit(CONNECTING, &con->state)) {
if (!test_bit(NEGOTIATING, &con->state)) {
dout("try_read %p connecting\n", con);
ret = read_partial_banner(con);
if (ret <= 0)