From 35b13266923f8095650f45562d66372e618c8824 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 10 Jul 2012 13:18:27 -0700 Subject: [PATCH] msgr: take over existing Connection on Pipe replacement If a new pipe/socket is taking over an existing session, it should also take over the Connection* associated with the existing session. Because we cannot clear existing->connection_state, we just take another reference. Clean up the comments a bit while we're here. This affects MDS<->client sessions when reconnecting after a socket fault. It probably also affects intra-cluster (osd/osd, mds/mds, mon/mon) sessions as well, but I did not confirm that. Backport: argonaut Signed-off-by: Sage Weil --- src/msg/SimpleMessenger.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/msg/SimpleMessenger.cc b/src/msg/SimpleMessenger.cc index 53e36cd7ef2d8..38282e7d14d50 100644 --- a/src/msg/SimpleMessenger.cc +++ b/src/msg/SimpleMessenger.cc @@ -845,14 +845,16 @@ int SimpleMessenger::Pipe::accept() existing->unregister_pipe(); replaced = true; - 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 */ + if (!existing->policy.lossy) { + // drop my Connection, and take a ref to the existing one. do not + // clear existing->connection_state, since read_message and + // write_message both dereference it without pipe_lock. + connection_state->put(); + connection_state = existing->connection_state->get(); + + // make existing Connection reference us existing->connection_state->reset_pipe(this); - // do not clear existing->connection_state, since read_message and write_message both - // dereference it without pipe_lock. - // steal incoming queue in_seq = existing->in_seq; in_seq_acked = in_seq; -- 2.39.5