+ it = m_clients.find(package.session());
+ if (it != m_clients.end())
+ {
+ Z_GDU *gdu = package.request().get();
+ if (gdu && gdu->which == Z_GDU_Z3950)
+ { // only Z39.50 packages lock in get_assoc.. release it
+ it->second->m_in_use = false;
+ it->second->m_queue_len--;
+ }
+
+ if (package.session().is_closed())
+ {
+ // 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);
+ }
+ m_cond_session_ready.notify_all();
+ }