From 203c514721559a0573ca4ec492f968249479c5f5 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 24 Feb 2004 20:55:56 +0000 Subject: [PATCH] Deal with init message sizes for reuse sessions --- ChangeLog | 4 ++++ TODO | 2 -- configure.in | 2 +- include/yaz++/proxy.h | 6 +++++- src/yaz-proxy.cpp | 40 ++++++++++++++++++++++++++++++++++++---- zlint/Makefile.am | 4 ++-- 6 files changed, 48 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index e26b147..06b1ea9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +--- 0.7.9 2004/02/24 Internal release. + +Deal with init message sizes for reuse sessions. + --- 0.7.8 2004/02/16 Internal release. For yaz-proxy, allow maximum number of files to be specified (setrlimit) with diff --git a/TODO b/TODO index d1b25c1..b3a5672 100644 --- a/TODO +++ b/TODO @@ -9,8 +9,6 @@ Live status (via search, present). Possible threading. -Deal with Z39.50 messages sizes properly. - Character set conversion for SRW queries. Throw proper CQL conversion error. diff --git a/configure.in b/configure.in index 7ea8a4f..6d13853 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ AC_INIT(configure.in) -AM_INIT_AUTOMAKE("yaz++",0.7.8) +AM_INIT_AUTOMAKE("yaz++",0.7.9) AC_PROG_CC AC_PROG_CPP diff --git a/include/yaz++/proxy.h b/include/yaz++/proxy.h index 649e0a2..e876aec 100644 --- a/include/yaz++/proxy.h +++ b/include/yaz++/proxy.h @@ -2,7 +2,7 @@ * Copyright (c) 1998-2004, Index Data. * See the file LICENSE for details. * - * $Id: proxy.h,v 1.39 2004-02-10 15:02:19 adam Exp $ + * $Id: proxy.h,v 1.40 2004-02-24 20:55:57 adam Exp $ */ #include @@ -171,6 +171,8 @@ class YAZ_EXPORT Yaz_ProxyClient : public Yaz_Z_Assoc { Z_APDU *m_initResponse; Z_Options *m_initResponse_options; Z_ProtocolVersion *m_initResponse_version; + int m_initResponse_preferredMessageSize; + int m_initResponse_maximumRecordSize; Yaz_RecordCache m_cache; void pre_init_client(); int m_target_idletime; @@ -251,6 +253,8 @@ class YAZ_EXPORT Yaz_Proxy : public Yaz_Z_Assoc { int convert_xsl(Z_NamePlusRecordList *p, Z_APDU *apdu); void convert_xsl_delay(); Z_APDU *m_initRequest_apdu; + int m_initRequest_preferredMessageSize; + int m_initRequest_maximumRecordSize; Z_Options *m_initRequest_options; Z_ProtocolVersion *m_initRequest_version; NMEM m_initRequest_mem; diff --git a/src/yaz-proxy.cpp b/src/yaz-proxy.cpp index 86da0d8..95996b2 100644 --- a/src/yaz-proxy.cpp +++ b/src/yaz-proxy.cpp @@ -2,7 +2,7 @@ * Copyright (c) 1998-2004, Index Data. * See the file LICENSE for details. * - * $Id: yaz-proxy.cpp,v 1.102 2004-02-16 10:47:37 adam Exp $ + * $Id: yaz-proxy.cpp,v 1.103 2004-02-24 20:55:57 adam Exp $ */ #include @@ -111,6 +111,8 @@ Yaz_Proxy::Yaz_Proxy(IYaz_PDU_Observable *the_PDU_Observable, m_schema = 0; m_initRequest_apdu = 0; m_initRequest_mem = 0; + m_initRequest_preferredMessageSize = 0; + m_initRequest_maximumRecordSize = 0; m_initRequest_options = 0; m_initRequest_version = 0; m_apdu_invalid_session = 0; @@ -1079,6 +1081,18 @@ int Yaz_Proxy::send_to_client(Z_APDU *apdu) ODR_MASK_SET(nopt, i); apdu->u.initResponse->protocolVersion = nopt; } + apdu->u.initResponse->preferredMessageSize = + odr_intdup(odr_encode(), + m_client->m_initResponse_preferredMessageSize > + m_initRequest_preferredMessageSize ? + m_initRequest_preferredMessageSize : + m_client->m_initResponse_preferredMessageSize); + apdu->u.initResponse->maximumRecordSize = + odr_intdup(odr_encode(), + m_client->m_initResponse_maximumRecordSize > + m_initRequest_maximumRecordSize ? + m_initRequest_maximumRecordSize : + m_client->m_initResponse_maximumRecordSize); } int r = send_PDU_convert(apdu); if (r) @@ -1971,6 +1985,13 @@ void Yaz_Proxy::handle_incoming_Z_PDU(Z_APDU *apdu) m_initRequest_apdu = apdu; m_initRequest_mem = odr_extract_mem(odr_decode()); + m_initRequest_preferredMessageSize = *apdu->u.initRequest-> + preferredMessageSize; + *apdu->u.initRequest->preferredMessageSize = 1024*1024; + m_initRequest_maximumRecordSize = *apdu->u.initRequest-> + maximumRecordSize; + *apdu->u.initRequest->maximumRecordSize = 1024*1024; + // save init options for the response.. m_initRequest_options = apdu->u.initRequest->options; @@ -2237,6 +2258,7 @@ void Yaz_Proxy::pre_init() { Yaz_ProxyClient *c; int spare = 0; + int spare_waiting = 0; int in_use = 0; int other = 0; for (c = m_clientPool; c; c = c->m_next) @@ -2246,7 +2268,10 @@ void Yaz_Proxy::pre_init() if (c->m_cookie == 0) { if (c->m_server == 0) - spare++; + if (c->m_waiting) + spare_waiting; + else + spare++; else in_use++; } @@ -2255,8 +2280,9 @@ void Yaz_Proxy::pre_init() } } yaz_log(LOG_LOG, "%spre-init %s %s use=%d other=%d spare=%d " - "preinit=%d",m_session_str, - name, zurl_in_use[j], in_use, other, spare, pre_init); + "sparew=%d preinit=%d",m_session_str, + name, zurl_in_use[j], in_use, other, + spare, spare_waiting, pre_init); if (spare < pre_init) { c = new Yaz_ProxyClient(m_PDU_Observable->clone(), this); @@ -2363,6 +2389,8 @@ Yaz_ProxyClient::Yaz_ProxyClient(IYaz_PDU_Observable *the_PDU_Observable, m_initResponse = 0; m_initResponse_options = 0; m_initResponse_version = 0; + m_initResponse_preferredMessageSize = 0; + m_initResponse_maximumRecordSize = 0; m_resultSetStartPoint = 0; m_bytes_sent = m_bytes_recv = 0; m_pdu_recv = 0; @@ -2430,6 +2458,10 @@ void Yaz_ProxyClient::recv_Z_PDU(Z_APDU *apdu, int len) m_initResponse = apdu; m_initResponse_options = apdu->u.initResponse->options; m_initResponse_version = apdu->u.initResponse->protocolVersion; + m_initResponse_preferredMessageSize = + *apdu->u.initResponse->preferredMessageSize; + m_initResponse_maximumRecordSize = + *apdu->u.initResponse->maximumRecordSize; Z_InitResponse *ir = apdu->u.initResponse; char *im0 = ir->implementationName; diff --git a/zlint/Makefile.am b/zlint/Makefile.am index b0ebe93..101dc63 100644 --- a/zlint/Makefile.am +++ b/zlint/Makefile.am @@ -1,9 +1,9 @@ -## $Id: Makefile.am,v 1.1 2004-02-18 22:11:41 adam Exp $ +## $Id: Makefile.am,v 1.2 2004-02-24 20:55:57 adam Exp $ AM_CXXFLAGS = $(YAZINC) -I$(srcdir)/../include $(XSLT_CFLAGS) zlint_SOURCES=zlint.cpp -bin_PROGRAMS = zlint +noinst_PROGRAMS = zlint LDADD=../src/libyazcpp.la $(YAZLALIB) $(XSLT_LIBS) -- 1.7.10.4