From: Adam Dickmeiss Date: Sat, 21 Apr 2012 08:24:44 +0000 (+0200) Subject: zoom: return addinfo="proxy failure" for proxy failures X-Git-Tag: v1.3.30~3 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=0e655a16ff31347f31878649bb0cf9bc6420469b;p=metaproxy-moved-to-github.git 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. --- 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;