From 1b73b30c27af204acc67f4d2deae1765fd3caf21 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 14 Jan 2004 12:14:13 +0000 Subject: [PATCH] Reconnect on dead sessions to target if client session is active. Fix bug with "present request out of range" if result count == 0 for SRW. --- include/yaz++/proxy.h | 3 ++- src/yaz-proxy.cpp | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/include/yaz++/proxy.h b/include/yaz++/proxy.h index 1224032..077a57d 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.33 2004-01-09 18:11:15 adam Exp $ + * $Id: proxy.h,v 1.34 2004-01-14 12:14:13 adam Exp $ */ #include @@ -283,6 +283,7 @@ class YAZ_EXPORT Yaz_Proxy : public Yaz_Z_Assoc { void failNotify(); void timeoutNotify(); void connectNotify(); + void markInvalid(); const char *option(const char *name, const char *value); void set_default_target(const char *target); void set_proxy_authentication (const char *auth); diff --git a/src/yaz-proxy.cpp b/src/yaz-proxy.cpp index 0ce638a..ed0d095 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.88 2004-01-12 22:35:59 adam Exp $ + * $Id: yaz-proxy.cpp,v 1.89 2004-01-14 12:14:13 adam Exp $ */ #include @@ -899,7 +899,7 @@ int Yaz_Proxy::send_PDU_convert(Z_APDU *apdu, int *len) { send_to_srw_client_ok(0, res->records, 1); } - else if (m_s2z_present_apdu) + else if (m_s2z_present_apdu && m_s2z_hit_count > 0) { // adjust Z_PresentRequest *pr = m_s2z_present_apdu->u.presentRequest; @@ -915,6 +915,7 @@ int Yaz_Proxy::send_PDU_convert(Z_APDU *apdu, int *len) } else { + m_s2z_present_apdu = 0; send_to_srw_client_ok(m_s2z_hit_count, res->records, 1); } } @@ -2183,6 +2184,12 @@ void Yaz_Proxy::timeoutNotify() } } +void Yaz_Proxy::markInvalid() +{ + m_client = 0; + m_invalid_session = 1; +} + void Yaz_ProxyClient::timeoutNotify() { if (m_server) @@ -2192,6 +2199,14 @@ void Yaz_ProxyClient::timeoutNotify() get_hostname()); m_waiting = 1; m_root->pre_init(); + if (m_server && m_init_flag) + { + // target timed out in a session that was properly initialized + // server object stay alive but we mark it as invalid so it + // gets initialized again + m_server->markInvalid(); + m_server = 0; + } shutdown(); } -- 1.7.10.4