X-Git-Url: http://sru.miketaylor.org.uk/?a=blobdiff_plain;f=src%2Ffilter_z3950_client.cpp;h=70f7703eb314c1d24e254f1a6752100dcddf6a9b;hb=665559cbc22546e8df69be33a7d492294cab9fb1;hp=6b27e7eb8a508afbcd0090eca7db9f8d04a66d98;hpb=09ce8a48eb9d2947cd019f9b8adb6513941c2211;p=metaproxy-moved-to-github.git diff --git a/src/filter_z3950_client.cpp b/src/filter_z3950_client.cpp index 6b27e7e..70f7703 100644 --- a/src/filter_z3950_client.cpp +++ b/src/filter_z3950_client.cpp @@ -70,6 +70,7 @@ namespace metaproxy_1 { int m_queue_len; int m_time_elapsed; int m_time_max; + int m_time_connect_max; std::string m_host; }; @@ -100,7 +101,7 @@ yf::Z3950Client::Assoc::Assoc(yazpp_1::SocketManager *socket_manager, m_socket_manager(socket_manager), m_PDU_Observable(PDU_Observable), m_package(0), m_in_use(true), m_waiting(false), m_destroyed(false), m_connected(false), m_queue_len(1), - m_time_elapsed(0), m_time_max(timeout_sec), + m_time_elapsed(0), m_time_max(timeout_sec), m_time_connect_max(10), m_host(host) { // std::cout << "create assoc " << this << "\n"; @@ -139,7 +140,8 @@ void yf::Z3950Client::Assoc::failNotify() void yf::Z3950Client::Assoc::timeoutNotify() { m_time_elapsed++; - if (m_time_elapsed >= m_time_max) + if ((m_connected && m_time_elapsed >= m_time_max) + || (!m_connected && m_time_elapsed >= m_time_connect_max)) { m_waiting = false; @@ -406,19 +408,14 @@ 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(); } } @@ -480,8 +477,9 @@ extern "C" { /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil - * c-file-style: "stroustrup" * End: * vim: shiftwidth=4 tabstop=8 expandtab */ +