X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fyaz-proxy.cpp;h=0a68075c72382cae26cb8d90928a1f79061fb4d3;hb=refs%2Ftags%2FYAZPROXY.1.1.0.3;hp=386f74cd9594f344090de3a0f8d9400eb63b62e8;hpb=453b15fc535beeea3dd98d78ccef61825f910b5e;p=yazproxy-moved-to-github.git diff --git a/src/yaz-proxy.cpp b/src/yaz-proxy.cpp index 386f74c..0a68075 100644 --- a/src/yaz-proxy.cpp +++ b/src/yaz-proxy.cpp @@ -1,4 +1,4 @@ -/* $Id: yaz-proxy.cpp,v 1.58 2006-04-15 15:54:38 adam Exp $ +/* $Id: yaz-proxy.cpp,v 1.60 2006-04-17 07:38:21 adam Exp $ Copyright (c) 1998-2006, Index Data. This file is part of the yazproxy. @@ -1848,6 +1848,25 @@ void Yaz_Proxy::recv_GDU(Z_GDU *apdu, int len) yaz_log (YLOG_LOG, "%sReceiving %s from client %d bytes", m_session_str, gdu_name(apdu), len); +#if 0 + // try to make a _bad_ attribute set ID .. Don't enable this in prod. + if (apdu->which == Z_GDU_Z3950 + && apdu->u.z3950->which == Z_APDU_searchRequest) + { + Z_SearchRequest *req = apdu->u.z3950->u.searchRequest; + if (req->query && req->query->which == Z_Query_type_1) + { + Z_RPNQuery *rpnquery = req->query->u.type_1; + if (rpnquery->attributeSetId) + { + rpnquery->attributeSetId[0] = -2; + rpnquery->attributeSetId[1] = -1; + yaz_log(YLOG_WARN, "%sBAD FIXUP TEST", m_session_str); + } + } + } +#endif + #if HAVE_GETTIMEOFDAY gettimeofday((struct timeval *) m_time_tv, 0); #endif @@ -1855,8 +1874,16 @@ void Yaz_Proxy::recv_GDU(Z_GDU *apdu, int len) m_pdu_stat.add_bytes(1); GDU *gdu = new GDU(apdu); - m_in_queue.enqueue(gdu); + if (gdu->get() == 0) + { + delete gdu; + yaz_log(YLOG_LOG, "%sUnable to encode package", m_session_str); + m_in_queue.clear(); + dec_ref(true); + return; + } + m_in_queue.enqueue(gdu); recv_GDU_more(false); } @@ -1982,7 +2009,10 @@ void Yaz_Proxy::recv_GDU_more(bool normal) while (m_timeout_mode == timeout_normal && (g = m_in_queue.dequeue())) { m_timeout_mode = timeout_busy; + inc_ref(); recv_GDU_reduce(g); + if (dec_ref(false)) + break; } } @@ -3242,6 +3272,7 @@ void Yaz_Proxy::releaseClient() bool Yaz_Proxy::dec_ref(bool main_ptr) { + main_ptr = false; assert(m_ref_count > 0); if (main_ptr) { @@ -3276,7 +3307,7 @@ void Yaz_ProxyClient::shutdown() if (m_server) { - m_waiting = 1; // ensure it's released from Proxy in releaseClient + m_waiting = 1; // ensure it's released from Yaz_Proxy::releaseClient m_server->dec_ref(true); } else @@ -3286,8 +3317,7 @@ void Yaz_ProxyClient::shutdown() void Yaz_Proxy::failNotify() { inc_request_no(); - yaz_log (YLOG_LOG, "%sConnection closed by client", - get_session_str()); + yaz_log (YLOG_LOG, "%sConnection closed by client", get_session_str()); dec_ref(true); }