Fixed bug #2229:crash in Z39.50 client module
authorAdam Dickmeiss <adam@indexdata.dk>
Wed, 27 Aug 2008 11:39:50 +0000 (13:39 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Wed, 27 Aug 2008 11:39:50 +0000 (13:39 +0200)
Fixed bug #2229:crash in Z39.50 client module. The release_assoc method
could be deleting the same object twice.

src/filter_z3950_client.cpp

index 6b27e7e..2294ec0 100644 (file)
@@ -406,17 +406,13 @@ void yf::Z3950Client::Rep::release_assoc(Package &package)
         {
             // destroy hint (send_and_receive)
             it->second->m_destroyed = true;
-            
-            // wait until no one is waiting for it.
-            while (it->second->m_queue_len)
-                m_cond_session_ready.wait(lock);
-            // the Z_Assoc and PDU_Assoc must be destroyed before
-            // the socket manager.. so pull that out.. first..
-            yazpp_1::SocketManager *s = it->second->m_socket_manager;
-            delete it->second;  // destroy Z_Assoc
-            delete s;    // then manager
-            m_clients.erase(it);
+            if (it->second->m_queue_len == 0)
+            {
+                yazpp_1::SocketManager *s = it->second->m_socket_manager;
+                delete it->second;  // destroy Z_Assoc
+                delete s;    // then manager
+                m_clients.erase(it);
+            }
         }
         yaz_log(YLOG_LOG, "Notify all release_assoc");
         m_cond_session_ready.notify_all();