driver/goodbye: refactor to do all cleanup and be idempotent
driver/goodbye: refactor to do all cleanup and be idempotent

Make the function a bit more generic by cleaning up (and notifying
about) all allocated resources, but only triggering the
NameOwnerChanged and unregistration if the peer was actually registered.

This means driver_goodbye() can be called both before the peer was
registered and after it has become a monitor and the right thing
will happen.

Move peer_flush_matches() into driver_goodbye() as it was otherwise
called before every call to driver_goodbye() after the recent
BecomeMonitor() refactoring.

Signed-off-by: Tom Gundersen <7c8224529a7c718e876cb2496c973509fde1e50e@jklm.no>

bus1/dbus-broker