From b23e9a676e80d7083d39cc913f61e5124b45da67 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 6 Apr 2006 17:09:16 +0000 Subject: [PATCH 01/16] Increase session buffer string --- include/yazproxy/proxy.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/yazproxy/proxy.h b/include/yazproxy/proxy.h index e80924f..e7bb085 100644 --- a/include/yazproxy/proxy.h +++ b/include/yazproxy/proxy.h @@ -1,4 +1,4 @@ -/* $Id: proxy.h,v 1.32 2006-04-06 16:25:21 adam Exp $ +/* $Id: proxy.h,v 1.33 2006-04-06 17:09:16 adam Exp $ Copyright (c) 1998-2006, Index Data. This file is part of the yazproxy. @@ -92,7 +92,7 @@ class YAZ_EXPORT Yaz_Proxy : public yazpp_1::Z_Assoc { long m_seed; char *m_optimize; int m_session_no; // sequence for each client session - char m_session_str[30]; // session string (time:session_no) + char m_session_str[200]; // session string (time:session_no) Yaz_ProxyConfig *m_config; char *m_config_fname; int m_bytes_sent; -- 1.7.10.4 From b276287e0e21b0bb267c5d5a7d87254ee1f5e29f Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 6 Apr 2006 17:23:14 +0000 Subject: [PATCH 02/16] Supply YAZ Proxy version in Z39.50 init responses --- etc/voyager.xml | 3 ++- src/yaz-proxy.cpp | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/etc/voyager.xml b/etc/voyager.xml index ce55a62..1e9bbcb 100644 --- a/etc/voyager.xml +++ b/etc/voyager.xml @@ -1,5 +1,5 @@ - + --> 10 5 + doc diff --git a/src/yaz-proxy.cpp b/src/yaz-proxy.cpp index 5de2824..151a57c 100644 --- a/src/yaz-proxy.cpp +++ b/src/yaz-proxy.cpp @@ -1,4 +1,4 @@ -/* $Id: yaz-proxy.cpp,v 1.51 2006-04-06 16:25:21 adam Exp $ +/* $Id: yaz-proxy.cpp,v 1.52 2006-04-06 17:23:14 adam Exp $ Copyright (c) 1998-2006, Index Data. This file is part of the yazproxy. @@ -3577,8 +3577,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'; -- 1.7.10.4 From 3dc1aeb73ab96d305ddbbe2e2194d118ac5dc6b9 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 12 Apr 2006 11:30:52 +0000 Subject: [PATCH 03/16] Fixed bug in Yaz_Proxy::get_client . When MAXCLIENTS is reached, the server to be "thrown out" was not destructed properly; now using dec_ref instead. Fixed bug in Yaz_ProxyClient::timeoutNotify where Yaz_Proxy pointer was read from a freed class; now reading pointer before free. --- src/yaz-proxy.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/yaz-proxy.cpp b/src/yaz-proxy.cpp index 151a57c..bf5fa4b 100644 --- a/src/yaz-proxy.cpp +++ b/src/yaz-proxy.cpp @@ -1,4 +1,4 @@ -/* $Id: yaz-proxy.cpp,v 1.52 2006-04-06 17:23:14 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. @@ -748,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 { @@ -764,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; @@ -3075,7 +3074,7 @@ void Yaz_Proxy::handle_incoming_Z_PDU(Z_APDU *apdu) else { // Z39.50 just shutdown - delete this; + timeout(0); return; } } @@ -3476,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, -- 1.7.10.4 From 9293a17764506be33ef98b1b4e66c13803cd9372 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 12 Apr 2006 11:46:06 +0000 Subject: [PATCH 04/16] Bump version to 1.1.0.1 --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index d90691e..362f9e6 100644 --- a/configure.ac +++ b/configure.ac @@ -1,8 +1,8 @@ dnl yazproxy, Index Data 1994-2006 dnl See the file LICENSE for details. -dnl $Id: configure.ac,v 1.1 2006-03-28 20:00:15 adam Exp $ +dnl $Id: configure.ac,v 1.2 2006-04-12 11:46:06 adam Exp $ AC_PREREQ(2.59) -AC_INIT([yazproxy],[1.1.0],[adam@indexdata.dk]) +AC_INIT([yazproxy],[1.1.0.1],[adam@indexdata.dk]) AC_CONFIG_SRCDIR(configure.ac) AC_CONFIG_AUX_DIR([config]) AM_INIT_AUTOMAKE([1.8]) -- 1.7.10.4 From 41e1069c089436d4ccae81dae22b574517add3d4 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 12 Apr 2006 11:55:38 +0000 Subject: [PATCH 05/16] Temporarily enable full log for access from IP with NIS GROUP client --- etc/config.xml | 29 +++++++++++++++-------------- src/yaz-proxy.cpp | 8 ++++++-- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/etc/config.xml b/etc/config.xml index c48eab2..6228571 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -1,5 +1,5 @@ - + localhost:9999 - 30 - 60 - a/b + 60 + 20 + - 1000000 - 1000 + 100000 + 100 2000000 - 60 + 10 100 3 @@ -37,20 +37,21 @@ dc - 0 + 2 iso-8859-1 pqf.properties + - 30 - 10 - 10 - 5 - client-requests server-requests client-ip +--> + 20 + + + + client-ip doc diff --git a/src/yaz-proxy.cpp b/src/yaz-proxy.cpp index bf5fa4b..27455b8 100644 --- a/src/yaz-proxy.cpp +++ b/src/yaz-proxy.cpp @@ -1,4 +1,4 @@ -/* $Id: yaz-proxy.cpp,v 1.53 2006-04-12 11:30:52 adam Exp $ +/* $Id: yaz-proxy.cpp,v 1.54 2006-04-12 11:55:42 adam Exp $ Copyright (c) 1998-2006, Index Data. This file is part of the yazproxy. @@ -470,8 +470,12 @@ IPDU_Observer *Yaz_Proxy::sessionNotify(IPDU_Observable new_proxy->set_default_target(m_default_target); new_proxy->m_max_clients = m_max_clients; new_proxy->m_log_mask = m_log_mask; + + if (!strcmp(peername, "tcp:163.121.19.82")) // NIS GROUP + new_proxy->m_log_mask = 255; + new_proxy->set_APDU_log(get_APDU_log()); - if (m_log_mask & PROXY_LOG_APDU_CLIENT) + if (new_proxy->m_log_mask & PROXY_LOG_APDU_CLIENT) new_proxy->set_APDU_yazlog(1); else new_proxy->set_APDU_yazlog(0); -- 1.7.10.4 From 8acbd42b3c2cc8fec0c3e1da777415cd6ba66820 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 13 Apr 2006 00:02:23 +0000 Subject: [PATCH 06/16] Use HTTP header X-Forwarded-For as IP for blocking if available (for the case it's behind a proxy). Failing that use the peer IP given by TCP/IP. The operation sequence number is now incremented for each operation (GET,POST,SEARCH etc). By mistake that was disabled. Log each HTTP request in a brief format (method followed by path). --- include/yazproxy/proxy.h | 7 ++-- src/yaz-proxy.cpp | 102 ++++++++++++++++++++++++++++++++++------------ 2 files changed, 79 insertions(+), 30 deletions(-) diff --git a/include/yazproxy/proxy.h b/include/yazproxy/proxy.h index e7bb085..5f015fe 100644 --- a/include/yazproxy/proxy.h +++ b/include/yazproxy/proxy.h @@ -1,4 +1,4 @@ -/* $Id: proxy.h,v 1.33 2006-04-06 17:09:16 adam Exp $ +/* $Id: proxy.h,v 1.34 2006-04-13 00:02:23 adam Exp $ Copyright (c) 1998-2006, Index Data. This file is part of the yazproxy. @@ -50,7 +50,7 @@ class Yaz_CharsetConverter; enum YAZ_Proxy_MARCXML_mode { none, - marcxml, + marcxml }; class Msg_Thread; @@ -66,6 +66,8 @@ class YAZ_EXPORT Yaz_Proxy : public yazpp_1::Z_Assoc { char *get_proxy(Z_OtherInformation **otherInfo); void get_charset_and_lang_negotiation(Z_OtherInformation **otherInfo, char **charstes, char **langs, int *selected); + void HTTP_Forwarded(Z_GDU *z_gdu); + void connect_stat(bool &block, int &reduce); Yaz_ProxyClient *get_client(Z_APDU *apdu, const char *cookie, const char *proxy_host); void srw_get_client(const char *db, const char **backend_db); @@ -107,7 +109,6 @@ class YAZ_EXPORT Yaz_Proxy : public yazpp_1::Z_Assoc { timeout_xsl } m_timeout_mode; - int m_initial_reduce; int m_max_connect; int m_max_connect_period; int m_limit_connect; diff --git a/src/yaz-proxy.cpp b/src/yaz-proxy.cpp index 27455b8..da1a101 100644 --- a/src/yaz-proxy.cpp +++ b/src/yaz-proxy.cpp @@ -1,4 +1,4 @@ -/* $Id: yaz-proxy.cpp,v 1.54 2006-04-12 11:55:42 adam Exp $ +/* $Id: yaz-proxy.cpp,v 1.55 2006-04-13 00:02:24 adam Exp $ Copyright (c) 1998-2006, Index Data. This file is part of the yazproxy. @@ -295,7 +295,6 @@ Yaz_Proxy::Yaz_Proxy(IPDU_Observable *the_PDU_Observable, m_ref_count = 1; m_main_ptr_dec = false; m_peername = 0; - m_initial_reduce = 0; } void Yaz_Proxy::inc_ref() @@ -376,7 +375,7 @@ void Yaz_Proxy::set_default_target(const char *target) void Yaz_Proxy::set_proxy_negotiation (const char *charset, const char *lang, const char *default_charset) { - yaz_log(YLOG_LOG, "%sSet the proxy negotiation: charset to '%s', " + yaz_log(YLOG_DEBUG, "%sSet the proxy negotiation: charset to '%s', " "default charset to '%s', language to '%s'", m_session_str, charset?charset:"none", default_charset?default_charset:"none", @@ -434,7 +433,7 @@ IPDU_Observer *Yaz_Proxy::sessionNotify(IPDU_Observable char session_str[200]; const char *peername = the_PDU_Observable->getpeername(); if (m_log_mask & PROXY_LOG_IP_CLIENT) - sprintf(session_str, "%ld:%d %s 0 ", + sprintf(session_str, "%ld:%d %.80s 0 ", (long) time(0), m_session_no, peername); else sprintf(session_str, "%ld:%d 0 ", @@ -443,26 +442,9 @@ IPDU_Observer *Yaz_Proxy::sessionNotify(IPDU_Observable yaz_log (YLOG_LOG, "%sNew session %s", session_str, peername); - m_connect.cleanup(false); - m_connect.add_connect(peername); - - int connect_total = m_connect.get_total(peername); - int connect_max = m_max_connect; - if (connect_max && connect_total > connect_max) - { - yaz_log(YLOG_LOG, "%sconnect not accepted total=%d max=%d", - session_str, connect_total, connect_max); - return 0; - } - yaz_log(YLOG_LOG, "%sconnect accepted total=%d", session_str, - connect_total); - Yaz_Proxy *new_proxy = new Yaz_Proxy(the_PDU_Observable, m_socket_observable, this); - if (m_limit_connect) - new_proxy->m_initial_reduce = connect_total / m_limit_connect; - new_proxy->m_config = 0; new_proxy->m_config_fname = 0; new_proxy->timeout(m_client_idletime); @@ -1846,6 +1828,7 @@ Z_APDU *Yaz_Proxy::result_set_optimize(Z_APDU *apdu) void Yaz_Proxy::inc_request_no() { + m_request_no++; char *cp = m_session_str + strlen(m_session_str)-1; if (*cp == ' ') cp--; @@ -1877,10 +1860,77 @@ void Yaz_Proxy::recv_GDU(Z_GDU *apdu, int len) recv_GDU_more(false); } +void Yaz_Proxy::HTTP_Forwarded(Z_GDU *z_gdu) +{ + if (z_gdu->which == Z_GDU_HTTP_Request) + { + Z_HTTP_Request *hreq = z_gdu->u.HTTP_Request; + const char *x_forwarded_for = + z_HTTP_header_lookup(hreq->headers, "X-Forwarded-For"); + if (x_forwarded_for) + { + xfree(m_peername); + m_peername = (char*) xmalloc(strlen(x_forwarded_for)+5); + sprintf(m_peername, "tcp:%s", x_forwarded_for); + + yaz_log(YLOG_LOG, "%sHTTP Forwarded from %s", m_session_str, + m_peername); + if (m_log_mask & PROXY_LOG_IP_CLIENT) + sprintf(m_session_str, "%ld:%d %.80s 0 ", + (long) time(0), m_session_no, m_peername); + else + sprintf(m_session_str, "%ld:%d 0 ", + (long) time(0), m_session_no); + } + } +} + +void Yaz_Proxy::connect_stat(bool &block, int &reduce) +{ + + m_parent->m_connect.cleanup(false); + m_parent->m_connect.add_connect(m_peername); + + int connect_total = m_parent->m_connect.get_total(m_peername); + int max_connect = m_parent->m_max_connect; + + if (max_connect && connect_total > max_connect) + { + yaz_log(YLOG_LOG, "%sconnect not accepted total=%d max=%d", + m_session_str, connect_total, max_connect); + block = true; + } + else + block = false; + yaz_log(YLOG_LOG, "%sconnect accepted total=%d", m_session_str, + connect_total); + + int limit_connect = m_parent->m_limit_connect; + if (limit_connect) + reduce = connect_total / limit_connect; + else + reduce = 0; +} + void Yaz_Proxy::recv_GDU_reduce(GDU *gdu) { - int reduce = m_initial_reduce; // initial reduce from connect phase.. - m_initial_reduce = 0; // reset it.. + HTTP_Forwarded(gdu->get()); + + int reduce = 0; + + if (m_request_no == 1) + { + bool block = false; + + connect_stat(block, reduce); + + if (block) + { + m_timeout_mode = timeout_busy; + timeout(0); + return; + } + } int bw_total = m_bw_stat.get_total(); int pdu_total = m_pdu_stat.get_total(); @@ -2499,11 +2549,7 @@ int Yaz_Proxy::file_access(Z_HTTP_Request *hreq) while (*cp) { if (*cp == '/' && strchr("/.", cp[1])) - { - yaz_log(YLOG_LOG, "%sRejecting path %s", m_session_str, - hreq->path); return 0; - } cp++; } @@ -2613,6 +2659,8 @@ void Yaz_Proxy::handle_incoming_HTTP(Z_HTTP_Request *hreq) Z_SRW_diagnostic *diagnostic = 0; int num_diagnostic = 0; + yaz_log(YLOG_LOG, "%s%s %s", m_session_str, hreq->method, hreq->path); + if (file_access(hreq)) { return; -- 1.7.10.4 From 1c06499b5828a3af557d9c423cf6baf7e01ff2a1 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 13 Apr 2006 00:02:50 +0000 Subject: [PATCH 07/16] Bump version to 1.1.0.2 --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 362f9e6..f807fbd 100644 --- a/configure.ac +++ b/configure.ac @@ -1,8 +1,8 @@ dnl yazproxy, Index Data 1994-2006 dnl See the file LICENSE for details. -dnl $Id: configure.ac,v 1.2 2006-04-12 11:46:06 adam Exp $ +dnl $Id: configure.ac,v 1.3 2006-04-13 00:02:50 adam Exp $ AC_PREREQ(2.59) -AC_INIT([yazproxy],[1.1.0.1],[adam@indexdata.dk]) +AC_INIT([yazproxy],[1.1.0.2],[adam@indexdata.dk]) AC_CONFIG_SRCDIR(configure.ac) AC_CONFIG_AUX_DIR([config]) AM_INIT_AUTOMAKE([1.8]) -- 1.7.10.4 From ab5b888148b9f2c490c46ffaf9fe3a01be73fb36 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 13 Apr 2006 00:10:19 +0000 Subject: [PATCH 08/16] Fix link to SRU home page --- doc/installation.xml | 4 ++-- doc/introduction.xml | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/installation.xml b/doc/installation.xml index 96ced05..a3f8a77 100644 --- a/doc/installation.xml +++ b/doc/installation.xml @@ -1,5 +1,5 @@ - + Installation You need a C++ compiler to compile and use YAZ proxy. @@ -24,7 +24,7 @@ libXSLT are installed. YAZ must be configured with libxml2 support. If not, - SRW/SRU + SRW/SRU is not supported. The YAZ Proxy uses libXSLT for record conversions via XSLT. diff --git a/doc/introduction.xml b/doc/introduction.xml index b9e0e03..51a3e6e 100644 --- a/doc/introduction.xml +++ b/doc/introduction.xml @@ -1,4 +1,4 @@ - + Introduction The YAZ Proxy is @@ -9,10 +9,10 @@ - SRW/SRU - server function, to allow any Z39.50 server to also support - the ZiNG - protocols + SRW/SRU + server function, to allow any + Z39.50 + server to also support the SRW/SRU protocols. -- 1.7.10.4 From 8bc5868c392af49bdbaf3c8cd372dbb1d8d6e777 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 13 Apr 2006 00:10:27 +0000 Subject: [PATCH 09/16] Bump year --- doc/yazproxy.xml.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/yazproxy.xml.in b/doc/yazproxy.xml.in index e5172f2..26e1182 100644 --- a/doc/yazproxy.xml.in +++ b/doc/yazproxy.xml.in @@ -8,7 +8,7 @@ ]> - + YAZ proxy User's Guide and Reference @@ -17,7 +17,7 @@ AdamDickmeiss - 1999-2005 + 1999-2006 Index Data Aps @@ -29,7 +29,7 @@ This manual covers version @VERSION@. - CVS ID: $Id: yazproxy.xml.in,v 1.4 2005-03-14 13:15:54 adam Exp $ + CVS ID: $Id: yazproxy.xml.in,v 1.5 2006-04-13 00:10:27 adam Exp $ -- 1.7.10.4 From 700507bf7216c231697bbb600ccea74f186dff2a Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 13 Apr 2006 00:41:11 +0000 Subject: [PATCH 10/16] Another fix for operation sequence number (m_request_no) --- src/yaz-proxy.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/yaz-proxy.cpp b/src/yaz-proxy.cpp index da1a101..adc5208 100644 --- a/src/yaz-proxy.cpp +++ b/src/yaz-proxy.cpp @@ -1,4 +1,4 @@ -/* $Id: yaz-proxy.cpp,v 1.55 2006-04-13 00:02:24 adam Exp $ +/* $Id: yaz-proxy.cpp,v 1.56 2006-04-13 00:41:11 adam Exp $ Copyright (c) 1998-2006, Index Data. This file is part of the yazproxy. @@ -433,12 +433,11 @@ IPDU_Observer *Yaz_Proxy::sessionNotify(IPDU_Observable char session_str[200]; const char *peername = the_PDU_Observable->getpeername(); if (m_log_mask & PROXY_LOG_IP_CLIENT) - sprintf(session_str, "%ld:%d %.80s 0 ", - (long) time(0), m_session_no, peername); + sprintf(session_str, "%ld:%d %.80s %d ", + (long) time(0), m_session_no, peername, 0); else - sprintf(session_str, "%ld:%d 0 ", - (long) time(0), m_session_no); - m_session_no++; + sprintf(session_str, "%ld:%d %d ", + (long) time(0), m_session_no, 0); yaz_log (YLOG_LOG, "%sNew session %s", session_str, peername); @@ -1876,11 +1875,11 @@ void Yaz_Proxy::HTTP_Forwarded(Z_GDU *z_gdu) yaz_log(YLOG_LOG, "%sHTTP Forwarded from %s", m_session_str, m_peername); if (m_log_mask & PROXY_LOG_IP_CLIENT) - sprintf(m_session_str, "%ld:%d %.80s 0 ", - (long) time(0), m_session_no, m_peername); + sprintf(m_session_str, "%ld:%d %.80s %d ", + (long) time(0), m_session_no, m_peername, m_request_no); else - sprintf(m_session_str, "%ld:%d 0 ", - (long) time(0), m_session_no); + sprintf(m_session_str, "%ld:%d %d ", + (long) time(0), m_session_no, m_request_no); } } } @@ -3245,6 +3244,7 @@ bool Yaz_Proxy::dec_ref(bool main_ptr) 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; -- 1.7.10.4 From d23c53d4b4493f88a73a11d166e2a1a1d0aa2dd5 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 13 Apr 2006 00:43:56 +0000 Subject: [PATCH 11/16] Remove log message --- src/yaz-proxy.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/yaz-proxy.cpp b/src/yaz-proxy.cpp index adc5208..14c2f5e 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.57 2006-04-13 00:43:56 adam Exp $ Copyright (c) 1998-2006, Index Data. This file is part of the yazproxy. @@ -3244,7 +3244,6 @@ bool Yaz_Proxy::dec_ref(bool main_ptr) 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; -- 1.7.10.4 From 453b15fc535beeea3dd98d78ccef61825f910b5e Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Sat, 15 Apr 2006 15:54:38 +0000 Subject: [PATCH 12/16] Increment session number again (was deleted by mistake in 1.56) --- src/yaz-proxy.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/yaz-proxy.cpp b/src/yaz-proxy.cpp index 14c2f5e..386f74c 100644 --- a/src/yaz-proxy.cpp +++ b/src/yaz-proxy.cpp @@ -1,4 +1,4 @@ -/* $Id: yaz-proxy.cpp,v 1.57 2006-04-13 00:43:56 adam Exp $ +/* $Id: yaz-proxy.cpp,v 1.58 2006-04-15 15:54:38 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); -- 1.7.10.4 From 734ebbe383eae5b7dbd04d3052be18639158d4ce Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Sun, 16 Apr 2006 07:33:13 +0000 Subject: [PATCH 13/16] For config, dont wan for module element --- src/yaz-proxy-config.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/yaz-proxy-config.cpp b/src/yaz-proxy-config.cpp index dbf03a5..040abc5 100644 --- a/src/yaz-proxy-config.cpp +++ b/src/yaz-proxy-config.cpp @@ -1,4 +1,4 @@ -/* $Id: yaz-proxy-config.cpp,v 1.30 2006-04-06 16:25:21 adam Exp $ +/* $Id: yaz-proxy-config.cpp,v 1.31 2006-04-16 07:33:13 adam Exp $ Copyright (c) 1998-2006, Index Data. This file is part of the yazproxy. @@ -1104,6 +1104,9 @@ void Yaz_ProxyConfig::get_generic_info(int *log_mask, else if (ptr->type == XML_ELEMENT_NODE && !strcmp((const char *) ptr->name, "docpath")) ; + else if (ptr->type == XML_ELEMENT_NODE && + !strcmp((const char *) ptr->name, "module")) + ; else if (ptr->type == XML_ELEMENT_NODE) { yaz_log(YLOG_WARN, "0 Unknown element %s in yazproxy config", -- 1.7.10.4 From b0a1f7ae808c0fc63a3b347421fbff3cdbe8791b Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Sun, 16 Apr 2006 07:35:06 +0000 Subject: [PATCH 14/16] Fixed a bug in Yaz_Proxy::recv_GDU_more . The reference count for Yaz_Proxy object is incremented/decremented in each call to recv_GDU_more and we break out if object was destructed .. --- src/yaz-proxy.cpp | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/yaz-proxy.cpp b/src/yaz-proxy.cpp index 386f74c..ea0e197 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.59 2006-04-16 07:35:06 adam Exp $ Copyright (c) 1998-2006, Index Data. This file is part of the yazproxy. @@ -1982,7 +1982,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; } } @@ -3087,6 +3090,23 @@ void Yaz_Proxy::handle_init(Z_APDU *apdu) void Yaz_Proxy::handle_incoming_Z_PDU(Z_APDU *apdu) { +#if 0 + // try to make a _bad_ attribute set ID .. Don't enable this in prod. + if (apdu->which == Z_APDU_searchRequest) + { + Z_SearchRequest *req = apdu->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 Z_ReferenceId **refid = get_referenceIdP(apdu); nmem_reset(m_referenceId_mem); if (refid && *refid) @@ -3242,6 +3262,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 +3297,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 +3307,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); } -- 1.7.10.4 From 1e2e736eef09428424ada345008ae45b34c5441f Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Sun, 16 Apr 2006 07:45:03 +0000 Subject: [PATCH 15/16] Describe period-connect --- doc/reference.xml | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/doc/reference.xml b/doc/reference.xml index 099fd21..aa5fe2b 100644 --- a/doc/reference.xml +++ b/doc/reference.xml @@ -731,7 +731,8 @@ The element max-connect is a child of element proxy and specifies the maximum number - of connections to be initiated within the last minute. + of connections to be initiated within the last minute (or + value of period-connect. If the maximum number is reached the proxy will terminate the @@ -744,11 +745,26 @@ The element max-connect is a child of element proxy and specifies the limit of number - of connections to be initiated within the last minute. + of connections to be initiated within the last minute (or + value of period-connect. - If the maximum number is reached the proxy delay the first operatation - in the session (Thus delaying the connection). + If the maximum number is reached the proxy delays the first operation + in the session by one second. + + + +
+ period-connect + + The element period-connect is a child of element + proxy and specifies period - in the number of seconds + that limit-connect and + max-connect + should measure connections. + + + If period-connect is omitted, 60 seconds is used.
@@ -824,7 +840,7 @@ Date: Sun, 16 Apr 2006 07:46:03 +0000 Subject: [PATCH 16/16] Bump version to 1.1.0.3 --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index f807fbd..688d7d4 100644 --- a/configure.ac +++ b/configure.ac @@ -1,8 +1,8 @@ dnl yazproxy, Index Data 1994-2006 dnl See the file LICENSE for details. -dnl $Id: configure.ac,v 1.3 2006-04-13 00:02:50 adam Exp $ +dnl $Id: configure.ac,v 1.4 2006-04-16 07:46:03 adam Exp $ AC_PREREQ(2.59) -AC_INIT([yazproxy],[1.1.0.2],[adam@indexdata.dk]) +AC_INIT([yazproxy],[1.1.0.3],[adam@indexdata.dk]) AC_CONFIG_SRCDIR(configure.ac) AC_CONFIG_AUX_DIR([config]) AM_INIT_AUTOMAKE([1.8]) -- 1.7.10.4