]> git.sesse.net Git - casparcg/blobdiff - protocol/util/AsyncEventServer.cpp
[AsyncEventServer] Avoid logging connection-close two times.
[casparcg] / protocol / util / AsyncEventServer.cpp
index cdfe538345206bbf36b72a7f881c66b269bebd9c..4add2e7496ab967dc3ec2ac9c4066081f0036fd4 100644 (file)
@@ -157,8 +157,14 @@ public:
 
        void disconnect()
        {
-               auto self = shared_from_this();
-               service_->dispatch([=] { self->stop(); });
+               std::weak_ptr<connection> self = shared_from_this();
+               service_->dispatch([=]
+               {
+                       auto strong = self.lock();
+
+                       if (strong)
+                               strong->stop();
+               });
        }
 
        void add_lifecycle_bound_object(const std::wstring& key, const std::shared_ptr<void>& lifecycle_bound)