X-Git-Url: http://sru.miketaylor.org.uk/?a=blobdiff_plain;ds=sidebyside;f=src%2Fyaz-proxy.cpp;h=bf5fa4b1c78199377334b1394543784e3f51d536;hb=3dc1aeb73ab96d305ddbbe2e2194d118ac5dc6b9;hp=a6930eaafabdcefc1a98a18841edaa02f69d57aa;hpb=2687af689ae79c5a823e28e0ecb3429106df1caa;p=yazproxy-moved-to-github.git diff --git a/src/yaz-proxy.cpp b/src/yaz-proxy.cpp index a6930ea..bf5fa4b 100644 --- a/src/yaz-proxy.cpp +++ b/src/yaz-proxy.cpp @@ -1,4 +1,4 @@ -/* $Id: yaz-proxy.cpp,v 1.50 2006-04-06 12:04:20 adam Exp $ +/* $Id: yaz-proxy.cpp,v 1.53 2006-04-12 11:30:52 adam Exp $ Copyright (c) 1998-2006, Index Data. This file is part of the yazproxy. @@ -232,8 +232,10 @@ Yaz_Proxy::Yaz_Proxy(IPDU_Observable *the_PDU_Observable, m_bw_max = 0; m_pdu_max = 0; m_search_max = 0; - m_connect_max = 0; + m_max_connect = 0; + m_max_connect_period = 0; m_limit_connect = 0; + m_limit_connect_period = 0; m_timeout_mode = timeout_normal; m_timeout_gdu = 0; m_max_record_retrieve = 0; @@ -354,8 +356,12 @@ int Yaz_Proxy::set_config(const char *config) m_config_fname = xstrdup(config); int r = m_config->read_xml(config); if (!r) + { + int period = 60; m_config->get_generic_info(&m_log_mask, &m_max_clients, - &m_connect_max, &m_limit_connect); + &m_max_connect, &m_limit_connect, &period); + m_connect.set_period(period); + } return r; } @@ -406,8 +412,11 @@ Yaz_ProxyConfig *Yaz_Proxy::check_reconfigure() else { m_log_mask = 0; + int period = 60; cfg->get_generic_info(&m_log_mask, &m_max_clients, - &m_connect_max, &m_limit_connect); + &m_max_connect, &m_limit_connect, + &period); + m_connect.set_period(period); } } else @@ -438,7 +447,7 @@ IPDU_Observer *Yaz_Proxy::sessionNotify(IPDU_Observable m_connect.add_connect(peername); int connect_total = m_connect.get_total(peername); - int connect_max = m_connect_max; + int connect_max = m_max_connect; if (connect_max && connect_total > connect_max) { yaz_log(YLOG_LOG, "%sconnect not accepted total=%d max=%d", @@ -739,8 +748,7 @@ Yaz_ProxyClient *Yaz_Proxy::get_client(Z_APDU *apdu, const char *cookie, yaz_log (YLOG_LOG, "%sMAXCLIENTS %d Destroy %d", m_session_str, parent->m_max_clients, c->m_seqno); if (c->m_server && c->m_server != this) - delete c->m_server; // PROBLEM: m_ref_count! - c->m_server = 0; + c->m_server->dec_ref(true); } else { @@ -755,7 +763,7 @@ Yaz_ProxyClient *Yaz_Proxy::get_client(Z_APDU *apdu, const char *cookie, if (c->m_server && c->m_server != this) { c->m_server->m_client = 0; - delete c->m_server; // PROBLEM: m_ref_count! + c->m_server->dec_ref(true); } (parent->m_seqno)++; c->m_target_idletime = m_target_idletime; @@ -3066,7 +3074,7 @@ void Yaz_Proxy::handle_incoming_Z_PDU(Z_APDU *apdu) else { // Z39.50 just shutdown - delete this; + timeout(0); return; } } @@ -3467,9 +3475,12 @@ void Yaz_ProxyClient::timeoutNotify() if (m_server) m_server->send_response_fail_client(get_hostname()); + + Yaz_Proxy *proxy_root = m_root; + shutdown(); - m_root->pre_init(); + proxy_root->pre_init(); } Yaz_ProxyClient::Yaz_ProxyClient(IPDU_Observable *the_PDU_Observable, @@ -3568,8 +3579,19 @@ void Yaz_ProxyClient::recv_Z_PDU(Z_APDU *apdu, int len) *apdu->u.initResponse->maximumRecordSize; Z_InitResponse *ir = apdu->u.initResponse; + + // apply YAZ Proxy version + char *imv0 = ir->implementationVersion; + char *imv1 = (char*) + odr_malloc(m_init_odr, 20 + (imv0 ? strlen(imv0) : 0)); + *imv1 = '\0'; + if (imv0) + strcat(imv1, imv0); + strcat(imv1, "/" VERSION); + ir->implementationVersion = imv1; + + // apply YAZ Proxy implementation name char *im0 = ir->implementationName; - char *im1 = (char*) odr_malloc(m_init_odr, 20 + (im0 ? strlen(im0) : 0)); *im1 = '\0';