From 0e655a16ff31347f31878649bb0cf9bc6420469b Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Sat, 21 Apr 2012 10:24:44 +0200 Subject: [PATCH] zoom: return addinfo="proxy failure" for proxy failures This commit also changes the scheme for dealing with proxies a bit. zoom now always do "proxy-check", even if there's no failover. Fortunately, that's not very expensive. --- src/filter_zoom.cpp | 51 +++++++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/src/filter_zoom.cpp b/src/filter_zoom.cpp index 894a5c5..15ff34a 100644 --- a/src/filter_zoom.cpp +++ b/src/filter_zoom.cpp @@ -1921,21 +1921,25 @@ next_proxy: BackendPtr b = get_backend_from_databases(package, db, &error, &addinfo, odr, &proxy_step, proxy); - if (error && same_retries == 0) + + if (error) { - if (proxy.length() && proxy_step && !m_p->check_proxy(proxy.c_str())) - { // we have a failover and the current one seems bad - proxy_retries++; - package.log("zoom", YLOG_WARN, "search failed: trying next proxy"); - m_backend.reset(); - goto next_proxy; + if (proxy.length() && !m_p->check_proxy(proxy.c_str())) + { + if (proxy_step) // there is a failover + { + proxy_retries++; + package.log("zoom", YLOG_WARN, "search failed: trying next proxy"); + m_backend.reset(); + goto next_proxy; + } + error = YAZ_BIB1_TEMPORARY_SYSTEM_ERROR; + addinfo = odr_strdup(odr, "proxy failure"); } - else if (proxy_retries == 0) + else if (same_retries == 0 && proxy_retries == 0) { - // only perform retry for same proxy if we've had no other - // retries at all same_retries++; - package.log("zoom", YLOG_WARN, "search failed: trying same proxy"); + package.log("zoom", YLOG_WARN, "search failed: trying first proxy"); m_backend.reset(); proxy_step = 0; goto next_proxy; @@ -2183,21 +2187,24 @@ next_proxy: ZOOM_query_destroy(q); } - if (error && same_retries == 0) + if (error) { - if (proxy.length() && proxy_step && !m_p->check_proxy(proxy.c_str())) - { // we have a failover and the current one seems bad - proxy_retries++; - package.log("zoom", YLOG_WARN, "search failed: trying next proxy"); - m_backend.reset(); - goto next_proxy; + if (proxy.length() && !m_p->check_proxy(proxy.c_str())) + { + if (proxy_step) // there is a failover + { + proxy_retries++; + package.log("zoom", YLOG_WARN, "search failed: trying next proxy"); + m_backend.reset(); + goto next_proxy; + } + error = YAZ_BIB1_TEMPORARY_SYSTEM_ERROR; + addinfo = odr_strdup(odr, "proxy failure"); } - else if (proxy_retries == 0) + else if (same_retries == 0 && proxy_retries == 0) { - // only perform retry for same proxy if we've had no other - // retries at all same_retries++; - package.log("zoom", YLOG_WARN, "search failed: trying same proxy"); + package.log("zoom", YLOG_WARN, "search failed: trying first proxy"); m_backend.reset(); proxy_step = 0; goto next_proxy; -- 1.7.10.4