This way old Pipes that have been replaced can't clear the new Pipe
out of a Connection's link.
We might attempt to instead sever the link between CLOSED Pipes and
their Connections more completely (eg, when the Connection gets a
new Pipe), but that will require more work to handle all the
cases, and this works for now.
Signed-off-by: Greg Farnum <greg@inktank.com>
return pipe->get();
return NULL;
}
- void clear_pipe() {
- Mutex::Locker l(lock);
- if (pipe) {
+ void clear_pipe(RefCountedObject *old_p) {
+ if(old_p == pipe) {
+ Mutex::Locker l(lock);
pipe->put();
pipe = NULL;
}
::close(p->sd);
ldout(cct,10) << "reaper reaped pipe " << p << " " << p->get_peer_addr() << dendl;
if (p->connection_state)
- p->connection_state->clear_pipe();
+ p->connection_state->clear_pipe(p);
p->put();
ldout(cct,10) << "reaper deleted pipe " << p << dendl;
}