libt2n: (tomj) fixed call of virtual function close() from destructor, fixed return...
[libt2n] / src / connection.cpp
index cc543b2..4abfad4 100644 (file)
@@ -31,9 +31,13 @@ namespace libt2n
 
 connection::~connection()
 {
-    // we want the connection_closed callbacks to be called before
-    // FIXME: Functios is virtual
-    close();
+    // Run close() manually since it's a virtual function
+    // and we are in the destructor.
+    if (!is_closed())
+    {
+        closed=true;
+        do_callbacks(connection_closed);
+    }
 
     do_callbacks(connection_deleted);
 }