[git] GnuPG - branch, STABLE-BRANCH-2-2, updated. gnupg-2.2.11-23-ge5abdb6

by Werner Koch cvs at cvs.gnupg.org
Tue Dec 11 13:41:30 CET 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU Privacy Guard".

The branch, STABLE-BRANCH-2-2 has been updated
       via  e5abdb6da7fa7cd4d146c7285b160277511bc230 (commit)
       via  b9d71ea64a694582739c18cfef9621b36d5371e9 (commit)
      from  f7ff25edadd474f83fccba6fd3c410eb8358bb22 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit e5abdb6da7fa7cd4d146c7285b160277511bc230
Author: Werner Koch <wk at gnupg.org>
Date:   Tue Dec 11 13:39:41 2018 +0100

    dirmngr: Retry another server from the pool on 502, 503, 504.
    
    * dirmngr/ks-engine-hkp.c (handle_send_request_error): Add arg
    http_status and handle it.
    (ks_hkp_search): Get http_status froms end_request and pass on to
    handle_send_request_error.
    (ks_hkp_get): Ditto.
    (ks_hkp_put): Ditto.
    --
    
    GnuPG-bug-id: 4175
    Signed-off-by: Werner Koch <wk at gnupg.org>
    (cherry picked from commit 05ef6282784495a77f4faf76c0de5bc85dfecf06)

diff --git a/dirmngr/ks-engine-hkp.c b/dirmngr/ks-engine-hkp.c
index 3645789..20d29e9 100644
--- a/dirmngr/ks-engine-hkp.c
+++ b/dirmngr/ks-engine-hkp.c
@@ -1310,7 +1310,7 @@ send_request (ctrl_t ctrl, const char *request, const char *hostportstr,
    down to zero. */
 static int
 handle_send_request_error (ctrl_t ctrl, gpg_error_t err, const char *request,
-                           unsigned int *tries_left)
+                           unsigned int http_status, unsigned int *tries_left)
 {
   int retry = 0;
 
@@ -1353,6 +1353,27 @@ handle_send_request_error (ctrl_t ctrl, gpg_error_t err, const char *request,
         }
       break;
 
+    case GPG_ERR_NO_DATA:
+      {
+        switch (http_status)
+          {
+          case 502: /* Bad Gateway  */
+            log_info ("marking host dead due to a %u (%s)\n",
+                      http_status, http_status2string (http_status));
+            if (mark_host_dead (request) && *tries_left)
+              retry = 1;
+            break;
+
+          case 503: /* Service Unavailable */
+          case 504: /* Gateway Timeout    */
+            log_info ("selecting a different host due to a %u (%s)",
+                      http_status, http_status2string (http_status));
+            retry = 1;
+            break;
+          }
+      }
+      break;
+
     default:
       break;
     }
@@ -1381,6 +1402,7 @@ ks_hkp_search (ctrl_t ctrl, parsed_uri_t uri, const char *pattern,
   int reselect;
   unsigned int httpflags;
   char *httphost = NULL;
+  unsigned int http_status;
   unsigned int tries = SEND_REQUEST_RETRIES;
 
   *r_fp = NULL;
@@ -1462,12 +1484,14 @@ ks_hkp_search (ctrl_t ctrl, parsed_uri_t uri, const char *pattern,
 
   /* Send the request.  */
   err = send_request (ctrl, request, hostport, httphost, httpflags,
-                      NULL, NULL, &fp, r_http_status);
-  if (handle_send_request_error (ctrl, err, request, &tries))
+                      NULL, NULL, &fp, &http_status);
+  if (handle_send_request_error (ctrl, err, request, http_status, &tries))
     {
       reselect = 1;
       goto again;
     }
+  if (r_http_status)
+    *r_http_status = http_status;
   if (err)
     {
       if (gpg_err_code (err) == GPG_ERR_NO_DATA)
@@ -1529,6 +1553,7 @@ ks_hkp_get (ctrl_t ctrl, parsed_uri_t uri, const char *keyspec, estream_t *r_fp)
   int reselect;
   char *httphost = NULL;
   unsigned int httpflags;
+  unsigned int http_status;
   unsigned int tries = SEND_REQUEST_RETRIES;
 
   *r_fp = NULL;
@@ -1601,8 +1626,8 @@ ks_hkp_get (ctrl_t ctrl, parsed_uri_t uri, const char *keyspec, estream_t *r_fp)
 
   /* Send the request.  */
   err = send_request (ctrl, request, hostport, httphost, httpflags,
-                      NULL, NULL, &fp, NULL);
-  if (handle_send_request_error (ctrl, err, request, &tries))
+                      NULL, NULL, &fp, &http_status);
+  if (handle_send_request_error (ctrl, err, request, http_status, &tries))
     {
       reselect = 1;
       goto again;
@@ -1676,6 +1701,7 @@ ks_hkp_put (ctrl_t ctrl, parsed_uri_t uri, const void *data, size_t datalen)
   int reselect;
   char *httphost = NULL;
   unsigned int httpflags;
+  unsigned int http_status;
   unsigned int tries = SEND_REQUEST_RETRIES;
 
   parm.datastring = NULL;
@@ -1714,8 +1740,8 @@ ks_hkp_put (ctrl_t ctrl, parsed_uri_t uri, const void *data, size_t datalen)
 
   /* Send the request.  */
   err = send_request (ctrl, request, hostport, httphost, 0,
-                      put_post_cb, &parm, &fp, NULL);
-  if (handle_send_request_error (ctrl, err, request, &tries))
+                      put_post_cb, &parm, &fp, &http_status);
+  if (handle_send_request_error (ctrl, err, request, http_status, &tries))
     {
       reselect = 1;
       goto again;

commit b9d71ea64a694582739c18cfef9621b36d5371e9
Author: Werner Koch <wk at gnupg.org>
Date:   Tue Dec 11 13:24:21 2018 +0100

    dirmngr: New function http_status2string.
    
    * dirmngr/http.c (http_status2string): New.
    --
    
    Right now only the standard 5xx codes.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>
    (cherry picked from commit dc61f4ecea5c9815cb00aeb25439978337c1fd64)

diff --git a/dirmngr/http.c b/dirmngr/http.c
index d37faa8..9f4afc8 100644
--- a/dirmngr/http.c
+++ b/dirmngr/http.c
@@ -3657,3 +3657,27 @@ http_prepare_redirect (http_redir_info_t *info, unsigned int status_code,
   *r_url = newurl;
   return 0;
 }
+
+
+/* Return string describing the http STATUS.  Returns an empty string
+ * for an unknown status.  */
+const char *
+http_status2string (unsigned int status)
+{
+  switch (status)
+    {
+    case 500: return "Internal Server Error";
+    case 501: return "Not Implemented";
+    case 502: return "Bad Gateway";
+    case 503: return "Service Unavailable";
+    case 504: return "Gateway Timeout";
+    case 505: return "HTTP version Not Supported";
+    case 506: return "Variant Also Negation";
+    case 507: return "Insufficient Storage";
+    case 508: return "Loop Detected";
+    case 510: return "Not Extended";
+    case 511: return "Network Authentication Required";
+    }
+
+  return "";
+}
diff --git a/dirmngr/http.h b/dirmngr/http.h
index a0458f8..2bad63d 100644
--- a/dirmngr/http.h
+++ b/dirmngr/http.h
@@ -197,5 +197,7 @@ gpg_error_t http_prepare_redirect (http_redir_info_t *info,
                                    unsigned int status_code,
                                    const char *location, char **r_url);
 
+const char *http_status2string (unsigned int status);
+
 
 #endif /*GNUPG_COMMON_HTTP_H*/

-----------------------------------------------------------------------

Summary of changes:
 dirmngr/http.c          | 24 ++++++++++++++++++++++++
 dirmngr/http.h          |  2 ++
 dirmngr/ks-engine-hkp.c | 40 +++++++++++++++++++++++++++++++++-------
 3 files changed, 59 insertions(+), 7 deletions(-)


hooks/post-receive
-- 
The GNU Privacy Guard
http://git.gnupg.org




More information about the Gnupg-commits mailing list