diff options
author | Alex Elder <elder@inktank.com> | 2012-05-23 15:35:23 -0400 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2012-07-06 00:14:27 -0400 |
commit | e27947c767f5bed15048f4e4dad3e2eb69133697 (patch) | |
tree | 7521d46e58b360930d95f7eeb86396d4f729db57 /net/ceph | |
parent | 3ec50d1868a9e0493046400bb1fdd054c7f64ebd (diff) |
libceph: define and use an explicit CONNECTED state
There is no state explicitly defined when a ceph connection is fully
operational. So define one.
It's set when the connection sequence completes successfully, and is
cleared when the connection gets closed.
Be a little more careful when examining the old state when a socket
disconnect event is reported.
Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
Diffstat (limited to 'net/ceph')
-rw-r--r-- | net/ceph/messenger.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index 500207bad5d6..83bcf977e9b9 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c | |||
@@ -463,6 +463,7 @@ void ceph_con_close(struct ceph_connection *con) | |||
463 | ceph_pr_addr(&con->peer_addr.in_addr)); | 463 | ceph_pr_addr(&con->peer_addr.in_addr)); |
464 | clear_bit(NEGOTIATING, &con->state); | 464 | clear_bit(NEGOTIATING, &con->state); |
465 | clear_bit(CONNECTING, &con->state); | 465 | clear_bit(CONNECTING, &con->state); |
466 | clear_bit(CONNECTED, &con->state); | ||
466 | clear_bit(STANDBY, &con->state); /* avoid connect_seq bump */ | 467 | clear_bit(STANDBY, &con->state); /* avoid connect_seq bump */ |
467 | set_bit(CLOSED, &con->state); | 468 | set_bit(CLOSED, &con->state); |
468 | 469 | ||
@@ -1564,6 +1565,7 @@ static int process_connect(struct ceph_connection *con) | |||
1564 | } | 1565 | } |
1565 | clear_bit(NEGOTIATING, &con->state); | 1566 | clear_bit(NEGOTIATING, &con->state); |
1566 | clear_bit(CONNECTING, &con->state); | 1567 | clear_bit(CONNECTING, &con->state); |
1568 | set_bit(CONNECTED, &con->state); | ||
1567 | con->peer_global_seq = le32_to_cpu(con->in_reply.global_seq); | 1569 | con->peer_global_seq = le32_to_cpu(con->in_reply.global_seq); |
1568 | con->connect_seq++; | 1570 | con->connect_seq++; |
1569 | con->peer_features = server_feat; | 1571 | con->peer_features = server_feat; |
@@ -2114,6 +2116,7 @@ more: | |||
2114 | prepare_read_ack(con); | 2116 | prepare_read_ack(con); |
2115 | break; | 2117 | break; |
2116 | case CEPH_MSGR_TAG_CLOSE: | 2118 | case CEPH_MSGR_TAG_CLOSE: |
2119 | clear_bit(CONNECTED, &con->state); | ||
2117 | set_bit(CLOSED, &con->state); /* fixme */ | 2120 | set_bit(CLOSED, &con->state); /* fixme */ |
2118 | goto out; | 2121 | goto out; |
2119 | default: | 2122 | default: |
@@ -2190,11 +2193,13 @@ static void con_work(struct work_struct *work) | |||
2190 | mutex_lock(&con->mutex); | 2193 | mutex_lock(&con->mutex); |
2191 | restart: | 2194 | restart: |
2192 | if (test_and_clear_bit(SOCK_CLOSED, &con->flags)) { | 2195 | if (test_and_clear_bit(SOCK_CLOSED, &con->flags)) { |
2193 | if (test_and_clear_bit(CONNECTING, &con->state)) { | 2196 | if (test_and_clear_bit(CONNECTED, &con->state)) |
2197 | con->error_msg = "socket closed"; | ||
2198 | else if (test_and_clear_bit(CONNECTING, &con->state)) { | ||
2194 | clear_bit(NEGOTIATING, &con->state); | 2199 | clear_bit(NEGOTIATING, &con->state); |
2195 | con->error_msg = "connection failed"; | 2200 | con->error_msg = "connection failed"; |
2196 | } else { | 2201 | } else { |
2197 | con->error_msg = "socket closed"; | 2202 | con->error_msg = "unrecognized con state"; |
2198 | } | 2203 | } |
2199 | goto fault; | 2204 | goto fault; |
2200 | } | 2205 | } |