cheshirekow / openbookfs

6.824 file synchronizer project
2 stars 3 forks source link

Handle the case where a connection is dropped and reinstated but the old connection still has an active worker doing jobs #4

Closed cheshirekow closed 11 years ago

cheshirekow commented 11 years ago

The simplest thing would be to put the RPC handler into a "holding pattern" while the worker is still doing jobs. If a client reconnects and the RPC handler is still around we can just give the sockfd to the old RPC handler. This way, there is at most one message queue per client.

cheshirekow commented 11 years ago

Handled this in the following way: the ClientMap is a map from [clientId]->[ClientHandler*]. When a client handler completes a handshake and discovers the client_id for the connected client, it attempts to insert itself into the map. When the connection breaks it removes itself from the map. If it tries to insert itself into the map but the map already contains an entry for that id then it waits on a condition variable until the map is modified. This condition variable is signalled when the other ClientHandler object removes itself from the map.

We may want to consider just aborting the connection if it's already in the map.