zoom: return addinfo="proxy failure" for proxy failures
authorAdam Dickmeiss <adam@indexdata.dk>
Sat, 21 Apr 2012 08:24:44 +0000 (10:24 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Sat, 21 Apr 2012 08:27:16 +0000 (10:27 +0200)
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

index 894a5c5..15ff34a 100644 (file)
@@ -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;