gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-anastasis] branch master updated: detect idempotency of truth upl


From: gnunet
Subject: [taler-anastasis] branch master updated: detect idempotency of truth uploads
Date: Wed, 17 Mar 2021 23:25:37 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository anastasis.

The following commit(s) were added to refs/heads/master by this push:
     new 99e6ed1  detect idempotency of truth uploads
99e6ed1 is described below

commit 99e6ed168b6bf0dae4f7c8adda6a9374737168e1
Author: Christian Grothoff <grothoff@gnunet.org>
AuthorDate: Wed Mar 17 23:25:34 2021 +0100

    detect idempotency of truth uploads
---
 src/backend/anastasis-httpd_truth_upload.c     | 43 +++++++++++++++++++++++---
 src/restclient/anastasis_api_keyshare_lookup.c |  2 +-
 src/restclient/anastasis_api_policy_store.c    |  2 +-
 src/restclient/anastasis_api_truth_store.c     |  2 +-
 4 files changed, 41 insertions(+), 8 deletions(-)

diff --git a/src/backend/anastasis-httpd_truth_upload.c 
b/src/backend/anastasis-httpd_truth_upload.c
index 80bd2f5..7e36438 100644
--- a/src/backend/anastasis-httpd_truth_upload.c
+++ b/src/backend/anastasis-httpd_truth_upload.c
@@ -191,10 +191,10 @@ make_payment_request (struct TruthUploadContext *tuc)
                        pfx,
                        hn,
                        order_id);
-      GNUNET_free (order_id);
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                   "Returning 402  %s\n",
                   order_id);
+      GNUNET_free (order_id);
     }
     GNUNET_break (MHD_YES ==
                   MHD_add_response_header (resp,
@@ -530,6 +530,9 @@ AH_handler_truth_post (
           = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply (
                                                 GNUNET_TIME_UNIT_MILLISECONDS,
                                                 timeout));
+        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                    "Long polling for %u ms enabled\n",
+                    timeout);
       }
       else
       {
@@ -656,10 +659,40 @@ AH_handler_truth_post (
                                        TALER_EC_GENERIC_DB_INVARIANT_FAILURE,
                                        "store_truth");
   case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
-    return TALER_MHD_reply_with_error (connection,
-                                       MHD_HTTP_CONFLICT,
-                                       
TALER_EC_ANASTASIS_TRUTH_UPLOAD_UUID_EXISTS,
-                                       NULL);
+    {
+      void *xtruth;
+      size_t xtruth_size;
+      char *xtruth_mime;
+      char *xmethod;
+      bool ok = false;
+
+      if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT ==
+          db->get_escrow_challenge (db->cls,
+                                    truth_uuid,
+                                    &xtruth,
+                                    &xtruth_size,
+                                    &xtruth_mime,
+                                    &xmethod))
+      {
+        ok = ( (xtruth_size == encrypted_truth_size) &&
+               (0 == strcmp (xmethod,
+                             type)) &&
+               (0 == strcmp (truth_mime,
+                             xtruth_mime)) &&
+               (0 == memcmp (xtruth,
+                             encrypted_truth,
+                             xtruth_size)) );
+        GNUNET_free (encrypted_truth);
+        GNUNET_free (xtruth_mime);
+        GNUNET_free (xmethod);
+      }
+      if (! ok)
+        return TALER_MHD_reply_with_error (connection,
+                                           MHD_HTTP_CONFLICT,
+                                           
TALER_EC_ANASTASIS_TRUTH_UPLOAD_UUID_EXISTS,
+                                           NULL);
+      /* idempotency detected, intentional fall through! */
+    }
   case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
     {
       struct MHD_Response *resp;
diff --git a/src/restclient/anastasis_api_keyshare_lookup.c 
b/src/restclient/anastasis_api_keyshare_lookup.c
index 3d41009..4708363 100644
--- a/src/restclient/anastasis_api_keyshare_lookup.c
+++ b/src/restclient/anastasis_api_keyshare_lookup.c
@@ -463,7 +463,7 @@ ANASTASIS_keyshare_lookup (
     GNUNET_assert (CURLE_OK ==
                    curl_easy_setopt (eh,
                                      CURLOPT_TIMEOUT_MS,
-                                     (long) tms));
+                                     (long) (tms + 5000)));
   GNUNET_assert (CURLE_OK ==
                  curl_easy_setopt (eh,
                                    CURLOPT_HEADERFUNCTION,
diff --git a/src/restclient/anastasis_api_policy_store.c 
b/src/restclient/anastasis_api_policy_store.c
index 0ce2e8d..b11ddc0 100644
--- a/src/restclient/anastasis_api_policy_store.c
+++ b/src/restclient/anastasis_api_policy_store.c
@@ -399,7 +399,7 @@ ANASTASIS_policy_store (
     GNUNET_assert (CURLE_OK ==
                    curl_easy_setopt (eh,
                                      CURLOPT_TIMEOUT_MS,
-                                     (long) tms));
+                                     (long) (tms + 5000)));
   GNUNET_assert (CURLE_OK ==
                  curl_easy_setopt (eh,
                                    CURLOPT_POSTFIELDS,
diff --git a/src/restclient/anastasis_api_truth_store.c 
b/src/restclient/anastasis_api_truth_store.c
index b385c63..5a75878 100644
--- a/src/restclient/anastasis_api_truth_store.c
+++ b/src/restclient/anastasis_api_truth_store.c
@@ -320,7 +320,7 @@ ANASTASIS_truth_store (
     GNUNET_assert (CURLE_OK ==
                    curl_easy_setopt (eh,
                                      CURLOPT_TIMEOUT_MS,
-                                     (long) tms));
+                                     (long) (tms + 5000)));
   GNUNET_assert (CURLE_OK ==
                  curl_easy_setopt (eh,
                                    CURLOPT_POSTFIELDS,

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]