Commit 3ec50d18 authored by Alex Elder's avatar Alex Elder Committed by Sage Weil

libceph: clear NEGOTIATING when done

A connection state's NEGOTIATING bit gets set while in CONNECTING
state after we have successfully exchanged a ceph banner and IP
addresses with the connection's peer (the server).  But that bit
is not cleared again--at least not until another connection attempt
is initiated.

Instead, clear it as soon as the connection is fully established.
Also, clear it when a socket connection gets prematurely closed
in the midst of establishing a ceph connection (in case we had
reached the point where it was set).
Signed-off-by: default avatarAlex Elder <elder@inktank.com>
Reviewed-by: default avatarSage Weil <sage@inktank.com>
parent bb9e6bba
...@@ -1562,6 +1562,7 @@ static int process_connect(struct ceph_connection *con) ...@@ -1562,6 +1562,7 @@ static int process_connect(struct ceph_connection *con)
fail_protocol(con); fail_protocol(con);
return -1; return -1;
} }
clear_bit(NEGOTIATING, &con->state);
clear_bit(CONNECTING, &con->state); clear_bit(CONNECTING, &con->state);
con->peer_global_seq = le32_to_cpu(con->in_reply.global_seq); con->peer_global_seq = le32_to_cpu(con->in_reply.global_seq);
con->connect_seq++; con->connect_seq++;
...@@ -1951,7 +1952,6 @@ static int try_write(struct ceph_connection *con) ...@@ -1951,7 +1952,6 @@ static int try_write(struct ceph_connection *con)
/* open the socket first? */ /* open the socket first? */
if (con->sock == NULL) { if (con->sock == NULL) {
clear_bit(NEGOTIATING, &con->state);
set_bit(CONNECTING, &con->state); set_bit(CONNECTING, &con->state);
con_out_kvec_reset(con); con_out_kvec_reset(con);
...@@ -2190,10 +2190,12 @@ static void con_work(struct work_struct *work) ...@@ -2190,10 +2190,12 @@ static void con_work(struct work_struct *work)
mutex_lock(&con->mutex); mutex_lock(&con->mutex);
restart: restart:
if (test_and_clear_bit(SOCK_CLOSED, &con->flags)) { if (test_and_clear_bit(SOCK_CLOSED, &con->flags)) {
if (test_and_clear_bit(CONNECTING, &con->state)) if (test_and_clear_bit(CONNECTING, &con->state)) {
clear_bit(NEGOTIATING, &con->state);
con->error_msg = "connection failed"; con->error_msg = "connection failed";
else } else {
con->error_msg = "socket closed"; con->error_msg = "socket closed";
}
goto fault; goto fault;
} }
......
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