History

libceph: start tracking connection socket state

Start explicitly keeping track of the state of a ceph connection's socket, separate from the state of the connection itself. Create placeholder functions to encapsulate the state transitions. -------- | NEW* | transient initial state -------- | con_sock_state_init() v ---------- | CLOSED | initialized, but no socket (and no ---------- TCP connection) ^ \ | \ con_sock_state_connecting() | ---------------------- | \ + con_sock_state_closed() \ |\ \ | \ \ | ----------- \ | | CLOSING | socket event; \ | ----------- await close \ | ^ | | | | | + con_sock_state_closing() | | / \ | | / --------------- | | / \ v | / -------------- | / -----------------| CONNECTING | socket created, TCP | | / -------------- connect initiated | | | con_sock_state_connected() | | v ------------- | CONNECTED | TCP connection established ------------- Make the socket state an atomic variable, reinforcing that it's a distinct transtion with no possible "intermediate/both" states. This is almost certainly overkill at this point, though the transitions into CONNECTED and CLOSING state do get called via socket callback (the rest of the transitions occur with the connection mutex held). We can back out the atomicity later.

Alex Elder committed 14 years ago

Commit ce2c8901 parent 928443c2 files · +70 −2Browse files

Showing the changes to include/linux/ceph (1 of 2 files). Show all

Unified · Split

include/linux/ceph/messenger.h+6−2
@@ -137,14 +137,18 @@ struct ceph_connection { · 136 unmodified lines
137137 const struct ceph_connection_operations *ops;
138138
139139 struct ceph_messenger *msgr;
140+
141+ atomic_t sock_state;
140142 struct socket *sock;
143+ struct ceph_entity_addr peer_addr; /* peer address */
144+ struct ceph_entity_addr peer_addr_for_me;
145+
141146 unsigned long flags;
142147 unsigned long state;
143148 const char *error_msg; /* error message, if any */
144149
145− struct ceph_entity_addr peer_addr; /* peer address */
146150 struct ceph_entity_name peer_name; /* peer name */
147− struct ceph_entity_addr peer_addr_for_me;
151+
148152 unsigned peer_features;
149153 u32 connect_seq; /* identify the most recent connection
150154 attempt for this connection, client */