From: Sage Weil Date: Mon, 24 Jan 2011 18:59:21 +0000 (-0800) Subject: msgr: make connection pipe reset atomic X-Git-Tag: v0.24.2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4a49a87db77a50f97848ffaf86f2b3c52409d454;p=ceph.git msgr: make connection pipe reset atomic Close a small and unlikely race. Signed-off-by: Sage Weil --- diff --git a/src/msg/Message.h b/src/msg/Message.h index 8e054d6a127..d161cb40334 100644 --- a/src/msg/Message.h +++ b/src/msg/Message.h @@ -212,6 +212,12 @@ public: 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; } diff --git a/src/msg/SimpleMessenger.cc b/src/msg/SimpleMessenger.cc index eb902bb048e..5f8f89929b9 100644 --- a/src/msg/SimpleMessenger.cc +++ b/src/msg/SimpleMessenger.cc @@ -876,8 +876,7 @@ int SimpleMessenger::Pipe::accept() 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;