Skip to content

Commit

Permalink
libceph: transition socket state prior to actual connect
Browse files Browse the repository at this point in the history
Once we call ->connect(), we are racing against the actual
connection, and a subsequent transition from CONNECTING ->
CONNECTED.  Set the state to CONNECTING before that, under the
protection of the mutex, to avoid the race.

This was introduced in 928443c,
with the original socket state code.

Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Alex Elder <elder@inktank.com>
  • Loading branch information
Sage Weil committed Jun 15, 2012
1 parent a550604 commit 89a86be
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions net/ceph/messenger.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ static int ceph_tcp_connect(struct ceph_connection *con)

dout("connect %s\n", ceph_pr_addr(&con->peer_addr.in_addr));

con_sock_state_connecting(con);
ret = sock->ops->connect(sock, (struct sockaddr *)paddr, sizeof(*paddr),
O_NONBLOCK);
if (ret == -EINPROGRESS) {
Expand All @@ -336,8 +337,6 @@ static int ceph_tcp_connect(struct ceph_connection *con)
return ret;
}
con->sock = sock;
con_sock_state_connecting(con);

return 0;
}

Expand Down

0 comments on commit 89a86be

Please sign in to comment.