async: match: stop pending sender on dtor

If the match is destructed with a pending Sender completion,
we need to 'stop' that Sender.  We cannot 'complete' the Sender
because we do not have a message (dbus signal) associated with the
match, but if we do nothing then the Sender is hung (and leaked).

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ia6e465d46f0f7da08a385cf7c875bbda88a5ab61
diff --git a/src/async/match.cpp b/src/async/match.cpp
index cee5c24..410e840 100644
--- a/src/async/match.cpp
+++ b/src/async/match.cpp
@@ -23,6 +23,21 @@
     slot = std::move(s);
 }
 
+match::~match()
+{
+    match_ns::match_completion* c = nullptr;
+
+    {
+        std::lock_guard l{lock};
+        c = std::exchange(complete, nullptr);
+    }
+
+    if (c)
+    {
+        c->stop();
+    }
+}
+
 void match_ns::match_completion::arm() noexcept
 {
     // Set ourselves as the awaiting Receiver and see if there is a message