aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2012-06-20 22:53:53 -0400
committerSage Weil <sage@inktank.com>2012-07-06 00:14:20 -0400
commit188048bce311ee41e5178bc3255415d0eae28423 (patch)
tree664eb69384323440f984f1fcd96075753fc1b286 /net
parenta8d00e3cdef4c1c4f194414b72b24cd995439a05 (diff)
libceph: don't change socket state on sock event
Currently the socket state change event handler records an error message on a connection to distinguish a close while connecting from a close while a connection was already established. Changing connection information during handling of a socket event is not very clean, so instead move this assignment inside con_work(), where it can be done during normal connection-level processing (and under protection of the connection mutex as well). Move the handling of a socket closed event up to the top of the processing loop in con_work(); there's no point in handling backoff etc. if we have a newly-closed socket to take care of. Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Sage Weil <sage@inktank.com>
Diffstat (limited to 'net')
-rw-r--r--net/ceph/messenger.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 39653944f21b..56381b973d02 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -261,13 +261,8 @@ static void ceph_sock_state_change(struct sock *sk)
261 case TCP_CLOSE_WAIT: 261 case TCP_CLOSE_WAIT:
262 dout("%s TCP_CLOSE_WAIT\n", __func__); 262 dout("%s TCP_CLOSE_WAIT\n", __func__);
263 con_sock_state_closing(con); 263 con_sock_state_closing(con);
264 if (test_and_set_bit(SOCK_CLOSED, &con->flags) == 0) { 264 if (!test_and_set_bit(SOCK_CLOSED, &con->flags))
265 if (test_bit(CONNECTING, &con->state))
266 con->error_msg = "connection failed";
267 else
268 con->error_msg = "socket closed";
269 queue_con(con); 265 queue_con(con);
270 }
271 break; 266 break;
272 case TCP_ESTABLISHED: 267 case TCP_ESTABLISHED:
273 dout("%s TCP_ESTABLISHED\n", __func__); 268 dout("%s TCP_ESTABLISHED\n", __func__);
@@ -2187,6 +2182,14 @@ static void con_work(struct work_struct *work)
2187 2182
2188 mutex_lock(&con->mutex); 2183 mutex_lock(&con->mutex);
2189restart: 2184restart:
2185 if (test_and_clear_bit(SOCK_CLOSED, &con->flags)) {
2186 if (test_bit(CONNECTING, &con->state))
2187 con->error_msg = "connection failed";
2188 else
2189 con->error_msg = "socket closed";
2190 goto fault;
2191 }
2192
2190 if (test_and_clear_bit(BACKOFF, &con->flags)) { 2193 if (test_and_clear_bit(BACKOFF, &con->flags)) {
2191 dout("con_work %p backing off\n", con); 2194 dout("con_work %p backing off\n", con);
2192 if (queue_delayed_work(ceph_msgr_wq, &con->work, 2195 if (queue_delayed_work(ceph_msgr_wq, &con->work,
@@ -2216,9 +2219,6 @@ restart:
2216 con_close_socket(con); 2219 con_close_socket(con);
2217 } 2220 }
2218 2221
2219 if (test_and_clear_bit(SOCK_CLOSED, &con->flags))
2220 goto fault;
2221
2222 ret = try_read(con); 2222 ret = try_read(con);
2223 if (ret == -EAGAIN) 2223 if (ret == -EAGAIN)
2224 goto restart; 2224 goto restart;