messages/MMonSync: initialize crc in ctor

Signed-off-by: Sage Weil <sage@inktank.com>
osd/ReplicatedPG: don't leak Session refs in do_osd_op_effects()

Signed-off-by: Sage Weil <sage@inktank.com>
osd: do not leak MOSDPings on shutdown

Signed-off-by: Sage Weil <sage@inktank.com>
osd: close classes on shutdown

Signed-off-by: Sage Weil <sage@inktank.com>
osd: do not leak HeartbeatSession on shutdown

Signed-off-by: Sage Weil <sage@inktank.com>
osd: break con <-> session cycle on reset

Signed-off-by: Sage Weil <sage@inktank.com>
mon: shut down Paxos on shutdown

This cleans up the completions for any paxos waiters.

Signed-off-by: Sage Weil <sage@inktank.com>
mon: add is_shutdown() state helper/accessor

Signed-off-by: Sage Weil <sage@inktank.com>
mon/PaxosService: discard messages during shutdown

Signed-off-by: Sage Weil <sage@inktank.com>
mon/MonClient: tear down version requests on shutdown

Make sure all callers can handle ECANCELED.

Signed-off-by: Sage Weil <sage@inktank.com>
msgr: use ConnectionRef throughout

Make RefCountedObject a private parent of Connection so that users are
forced to use ConnectionRef whenever references are taken.

Many methods can still take a raw Connection* when they are using the
caller's reference but not taking their own; this is cheaper than
twiddling the reference count, and the lifetime is still well defined.
Local variables generally use ConnectionRef, though.

Signed-off-by: Sage Weil <sage@inktank.com>
msg/Pipe: reset replaced pipes

This gives the ms_handle_reset call a chance to clean up (for example, by
breaking a con->priv <-> session reference cycle).

Signed-off-by: Sage Weil <sage@inktank.com>
msg/Pipe: include con reef in debug prestring

Signed-off-by: Sage Weil <sage@inktank.com>
msgr: queue reset exactly once on any connection

Use the atomic pipe link removal as a signal that we are the one failing
the con and use that to queue the reset event.

This fixes the case where we have an open, the session gets set up via the
handle_accept callback, and then race with another connection and go into
wait + close, or just close.  In that case, fault() needs to queue a reset
event to match the accept.

Signed-off-by: Sage Weil <sage@inktank.com>
msg/DispatchQueue: do not discard queued events on stop

When the shutdown/stop flag is set, continue to work through the queue.
Process events, but discard messages.  This avoids the loss of reset events
on shutdown that are necessary to clean up ref cycles.

Signed-off-by: Sage Weil <sage@inktank.com>
msgr: queue reset when marking down pipes on shutdown

This lets the callbacks clean up ref cycles.

Signed-off-by: Sage Weil <sage@inktank.com>
mon/MonClient: mark_down connection on shutdown

Signed-off-by: Sage Weil <sage@inktank.com>
mon/MonClient: mark_down during get_monmap_privately() shutdown

We explicitly mark_down() and clear cur_con when shutting down; do the same
for get_monmap_privately() to ensure that the reset event doesn't make us
do something silly (like, in this case, call _reopen_session() again).

Signed-off-by: Sage Weil <sage@inktank.com>
Merge pull request #356 from ceph/wip-leaks

Reviewed-by: Samuel Just <sam.just@inktank.com>