Closed cheshirekow closed 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.
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.