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=adc52086ef16a1554f71727e0d614bd04370280d;hpb=700507bf7216c231697bbb600ccea74f186dff2a;p=yazproxy-moved-to-github.git diff --git a/src/yaz-proxy.cpp b/src/yaz-proxy.cpp index adc5208..0a68075 100644 --- a/src/yaz-proxy.cpp +++ b/src/yaz-proxy.cpp @@ -1,4 +1,4 @@ -/* $Id: yaz-proxy.cpp,v 1.56 2006-04-13 00:41:11 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. @@ -438,6 +438,7 @@ IPDU_Observer *Yaz_Proxy::sessionNotify(IPDU_Observable else sprintf(session_str, "%ld:%d %d ", (long) time(0), m_session_no, 0); + m_session_no++; yaz_log (YLOG_LOG, "%sNew session %s", session_str, peername); @@ -1847,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 @@ -1854,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); } @@ -1981,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; } } @@ -3241,10 +3272,10 @@ void Yaz_Proxy::releaseClient() bool Yaz_Proxy::dec_ref(bool main_ptr) { + main_ptr = false; assert(m_ref_count > 0); if (main_ptr) { - yaz_log(YLOG_LOG, "%sdec_ref", m_session_str); if (m_main_ptr_dec) return false; m_main_ptr_dec = true; @@ -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); }