X-Git-Url: http://sru.miketaylor.org.uk/?a=blobdiff_plain;f=src%2Fyaz-proxy.cpp;h=6abcbd7a21de4b8d9de3950fa37d813bb333fee5;hb=2bf4929fe90ac9500d8345f5ccf1e1e306ab27d6;hp=147d066195aa563b2e1e23b696977f7e0a5583e8;hpb=d119ba229b6c9257c4efb634bf7425d6595196ff;p=yazproxy-moved-to-github.git diff --git a/src/yaz-proxy.cpp b/src/yaz-proxy.cpp index 147d066..6abcbd7 100644 --- a/src/yaz-proxy.cpp +++ b/src/yaz-proxy.cpp @@ -1,7 +1,5 @@ -/* $Id: yaz-proxy.cpp,v 1.78 2008-02-21 09:33:23 adam Exp $ - Copyright (c) 1998-2008, Index Data. - -This file is part of the yazproxy. +/* This file is part of YAZ proxy + Copyright (C) 1998-2008 Index Data YAZ proxy is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -14,10 +12,9 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with YAZ proxy; see the file LICENSE. If not, write to the -Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. - */ +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ #ifdef WIN32 #define HAVE_SYS_STAT_H 1 @@ -961,53 +958,30 @@ void Yaz_Proxy::convert_to_frontend_type(Z_NamePlusRecordList *p) Z_External *r = npr->u.databaseRecord; if (r->which == Z_External_octet) { -#if HAVE_USEMARCON +#if !HAVE_USEMARCON if (m_usemarcon_ini_stage1 && *m_usemarcon_ini_stage1) + yaz_log (YLOG_LOG, "%sError: USEMARCON requested but not available", + m_session_str); +#endif +#if HAVE_USEMARCON + yaz_log (YLOG_DEBUG, "%sUSEMARCON stage1=%s stage2=%s", + m_session_str, + m_usemarcon_ini_stage1 ? m_usemarcon_ini_stage1 : "(none)", + m_usemarcon_ini_stage2 ? m_usemarcon_ini_stage2 : "(none)"); + char *converted; + int convlen; + if (m_usemarcon->convert(m_usemarcon_ini_stage1, m_usemarcon_ini_stage2, + (char*) r->u.octet_aligned->buf, r->u.octet_aligned->len, + &converted, &convlen)) { - if (!m_usemarcon->m_stage1) - { - m_usemarcon->m_stage1 = new CDetails(); - } - m_usemarcon->m_stage1->SetIniFileName(m_usemarcon_ini_stage1); - m_usemarcon->m_stage1->SetMarcRecord((char*) r->u.octet_aligned->buf, r->u.octet_aligned->len); - int res = m_usemarcon->m_stage1->Start(); - if (res == 0) - { - char *converted; - int convlen; - m_usemarcon->m_stage1->GetMarcRecord(converted, convlen); - if (m_usemarcon_ini_stage2 && *m_usemarcon_ini_stage2) - { - if (!m_usemarcon->m_stage2) - { - m_usemarcon->m_stage2 = new CDetails(); - } - m_usemarcon->m_stage2->SetIniFileName(m_usemarcon_ini_stage2); - m_usemarcon->m_stage2->SetMarcRecord(converted, convlen); - res = m_usemarcon->m_stage2->Start(); - if (res == 0) - { - free(converted); - m_usemarcon->m_stage2->GetMarcRecord(converted, convlen); - } - else - { - yaz_log(YLOG_LOG, "%sUSEMARCON stage 2 error %d", m_session_str, res); - } - } - npr->u.databaseRecord = - z_ext_record_oid(odr_encode(), - m_frontend_type, - converted, - strlen(converted)); - free(converted); - } - else - { - yaz_log(YLOG_LOG, "%sUSEMARCON stage 1 error %d", m_session_str, res); - } - continue; + npr->u.databaseRecord = + z_ext_record_oid(odr_encode(), + m_frontend_type, + converted, + strlen(converted)); + free(converted); } + else #endif /* HAVE_USEMARCON */ npr->u.databaseRecord = @@ -2827,16 +2801,6 @@ void Yaz_Proxy::handle_incoming_HTTP(Z_HTTP_Request *hreq) } auth->u.idPass->userId = odr_strdup(m_s2z_odr_init, authorization_str); } - else - { - // Use _client_ IP as shown in the log entries...! - auth = (Z_IdAuthentication *) odr_malloc(m_s2z_odr_init, sizeof(Z_IdAuthentication)); - auth->which = Z_IdAuthentication_idPass; - auth->u.idPass = (Z_IdPass *) odr_malloc(m_s2z_odr_init, sizeof(Z_IdPass)); - auth->u.idPass->groupId = NULL; - auth->u.idPass->password = NULL; - auth->u.idPass->userId = odr_strdup(m_s2z_odr_init, m_peername); - } } if (srw_pdu->which == Z_SRW_searchRetrieve_request) @@ -3539,6 +3503,7 @@ void Yaz_Proxy::pre_init() const char *zurl_in_use[MAX_ZURL_PLEX]; int limit_bw, limit_pdu, limit_req, limit_search; int target_idletime, client_idletime; + int max_sockets; int max_clients; int keepalive_limit_bw, keepalive_limit_pdu; int pre_init; @@ -3560,6 +3525,7 @@ void Yaz_Proxy::pre_init() &limit_bw, &limit_pdu, &limit_req, &limit_search, &target_idletime, &client_idletime, + &max_sockets, &max_clients, &keepalive_limit_bw, &keepalive_limit_pdu, @@ -3603,7 +3569,8 @@ void Yaz_Proxy::pre_init() "sparew=%d preinit=%d",m_session_str, name, zurl_in_use[j], in_use, other, spare, spare_waiting, pre_init); - if (spare + spare_waiting < pre_init) + if (spare + spare_waiting < pre_init + && in_use + spare + spare_waiting + other < max_sockets) { c = new Yaz_ProxyClient(m_PDU_Observable->clone(), this); c->m_next = m_clientPool;