Close a small and unlikely race.
Signed-off-by: Sage Weil <sage@newdream.net>
pipe = NULL;
}
}
+ void reset_pipe(RefCountedObject *p) {
+ Mutex::Locker l(lock);
+ if (pipe)
+ pipe->put();
+ pipe = p->get();
+ }
int get_peer_type() { return peer_type; }
void set_peer_type(int t) { peer_type = t; }
if (!existing->policy.lossy) { /* if we're lossy, we can lose messages and
should let the daemon handle it itself.
Otherwise, take over other Connection so we don't lose older messages */
- existing->connection_state->clear_pipe();
- existing->connection_state->pipe = get();
+ existing->connection_state->reset_pipe(this);
existing->connection_state->put();
existing->connection_state = NULL;