gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-exchange] branch master updated (1541f2c2 -> 6982ccd


From: gnunet
Subject: [GNUnet-SVN] [taler-exchange] branch master updated (1541f2c2 -> 6982ccd7)
Date: Sun, 19 Aug 2018 13:07:36 +0200

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

grothoff pushed a change to branch master
in repository exchange.

    from 1541f2c2 fix test setup invocation
     new 433fab96 add logic to retry /keys if /keys download fails
     new 6982ccd7 force TALER_EXCHANGE_connect() va-list to be actually provided

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../.config/taler/account-2.json                   |  4 +-
 src/exchange-lib/exchange_api_handle.c             | 62 +++++++++++++++++-----
 src/exchange-lib/test_exchange_api.c               |  3 +-
 .../test_exchange_api_keys_cherry_picking.c        |  6 ++-
 .../test_exchange_api_keys_cherry_picking_new.c    |  9 +---
 src/exchange-lib/testing_api_loop.c                |  3 +-
 6 files changed, 61 insertions(+), 26 deletions(-)

diff --git a/src/benchmark/exchange_benchmark_home/.config/taler/account-2.json 
b/src/benchmark/exchange_benchmark_home/.config/taler/account-2.json
index 9bd77985..49114a10 100644
--- a/src/benchmark/exchange_benchmark_home/.config/taler/account-2.json
+++ b/src/benchmark/exchange_benchmark_home/.config/taler/account-2.json
@@ -1,5 +1,5 @@
 {
   "url": "payto://x-taler-bank/localhost:8082/2",
-  "salt": 
"04NPZ9DY6SQZHKNNFPYRNND7H7J7M9EG1RMY56F1PE7RKV16SMDCG2EK0F12GF6KP558VRE4QWPEG421X163YBVCSK17JQDHQFPBY50",
-  "master_sig": 
"8XQ6CFKNN0RFQMCVPVSMF650Z012X4TR68VTMT35W6R0E24G2XY0Q1E5G32YVX4P3928TB32H0JETMGSMMSREKA2Z7YA6FJZX6HQA0R"
+  "salt": 
"B9H7WG3A6881HNVK7C508EHMJ10Z0CEB21Z9047KXKMCZG67JK5M27EQNRW38KNPVXDYNYTX27PA34VSA8JN3NXJA0BX655WGJMM7B8",
+  "master_sig": 
"FCJAM149MFKTMD8XQ7S32TBD53VN97Y3BCXFXSGQ8DH94P18XXCPRA3Z9ZYBQ4JFFEPS4RE48ACS99MMM193QZ10M7MKGS2B685F030"
 }
\ No newline at end of file
diff --git a/src/exchange-lib/exchange_api_handle.c 
b/src/exchange-lib/exchange_api_handle.c
index 6a622233..1d8a31b7 100644
--- a/src/exchange-lib/exchange_api_handle.c
+++ b/src/exchange-lib/exchange_api_handle.c
@@ -1,6 +1,6 @@
 /*
   This file is part of TALER
-  Copyright (C) 2014-2017 GNUnet e.V.
+  Copyright (C) 2014-2018 GNUnet e.V.
 
   TALER is free software; you can redistribute it and/or modify it under the
   terms of the GNU General Public License as published by the Free Software
@@ -113,21 +113,31 @@ struct TALER_EXCHANGE_Handle
   struct KeysRequest *kr;
 
   /**
+   * Task for retrying /keys request.
+   */
+  struct GNUNET_SCHEDULER_Task *retry_task;
+
+  /**
+   * Raw key data of the exchange, only valid if
+   * @e handshake_complete is past stage #MHS_CERT.
+   */
+  json_t *key_data_raw;
+
+  /**
    * Key data of the exchange, only valid if
    * @e handshake_complete is past stage #MHS_CERT.
    */
   struct TALER_EXCHANGE_Keys key_data;
 
   /**
-   * When does @e key_data expire?
+   * Retry /keys frequency.
    */
-  struct GNUNET_TIME_Absolute key_data_expiration;
+  struct GNUNET_TIME_Relative retry_delay;
 
   /**
-   * Raw key data of the exchange, only valid if
-   * @e handshake_complete is past stage #MHS_CERT.
+   * When does @e key_data expire?
    */
-  json_t *key_data_raw;
+  struct GNUNET_TIME_Absolute key_data_expiration;
 
   /**
    * Stage of the exchange's initialization routines.
@@ -768,10 +778,10 @@ free_key_data (struct TALER_EXCHANGE_Keys *key_data)
 /**
  * Initiate download of /keys from the exchange.
  *
- * @param exchange where to download /keys from
+ * @param cls exchange where to download /keys from
  */
 static void
-request_keys (struct TALER_EXCHANGE_Handle *exchange);
+request_keys (void *cls);
 
 
 /**
@@ -791,7 +801,9 @@ TALER_EXCHANGE_check_keys_current (struct 
TALER_EXCHANGE_Handle *exchange,
   if ( (GNUNET_NO == force_download) &&
        (0 < GNUNET_TIME_absolute_get_remaining 
(exchange->key_data_expiration).rel_value_us) )
     return exchange->key_data_expiration;
-  request_keys (exchange);
+  if (NULL == exchange->retry_task)
+    exchange->retry_task = GNUNET_SCHEDULER_add_now (&request_keys,
+                                                     exchange);
   return GNUNET_TIME_UNIT_ZERO_ABS;
 }
 
@@ -827,6 +839,13 @@ keys_completed_cb (void *cls,
   switch (response_code)
   {
   case 0:
+    free_keys_request (kr);
+    exchange->kr = NULL;
+    GNUNET_assert (NULL == exchange->retry_task);
+    exchange->retry_delay = GNUNET_TIME_STD_BACKOFF (exchange->retry_delay);
+    exchange->retry_task = GNUNET_SCHEDULER_add_delayed (exchange->retry_delay,
+                                                         &request_keys,
+                                                         exchange);
     break;
   case MHD_HTTP_OK:
     if (NULL == resp_obj)
@@ -882,6 +901,7 @@ keys_completed_cb (void *cls,
     }
     json_decref (exchange->key_data_raw);
     exchange->key_data_raw = json_deep_copy (resp_obj);
+    exchange->retry_delay = GNUNET_TIME_UNIT_ZERO;
     break;
   default:
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -1076,8 +1096,10 @@ header_cb (char *buffer,
   return total;
 }
 
+
 /* ********************* public API ******************* */
 
+
 /**
  * Initialise a connection to the exchange. Will connect to the
  * exchange and obtain information about the exchange's master public
@@ -1101,13 +1123,19 @@ TALER_EXCHANGE_connect (struct GNUNET_CURL_Context *ctx,
                         ...)
 {
   struct TALER_EXCHANGE_Handle *exchange;
+  va_list ap;
 
+  va_start (ap, cert_cb_cls);
+  GNUNET_assert (TALER_EXCHANGE_OPTION_END ==
+                 va_arg (ap, int));
+  va_end (ap);
   exchange = GNUNET_new (struct TALER_EXCHANGE_Handle);
   exchange->ctx = ctx;
   exchange->url = GNUNET_strdup (url);
   exchange->cert_cb = cert_cb;
   exchange->cert_cb_cls = cert_cb_cls;
-  request_keys (exchange);
+  exchange->retry_task = GNUNET_SCHEDULER_add_now (&request_keys,
+                                                   exchange);
   return exchange;
 }
 
@@ -1115,18 +1143,21 @@ TALER_EXCHANGE_connect (struct GNUNET_CURL_Context *ctx,
 /**
  * Initiate download of /keys from the exchange.
  *
- * @param exchange where to download /keys from
+ * @param cls exchange where to download /keys from
  */
 static void
-request_keys (struct TALER_EXCHANGE_Handle *exchange)
+request_keys (void *cls)
 {
+  struct TALER_EXCHANGE_Handle *exchange = cls;
   struct KeysRequest *kr;
   CURL *eh;
 
+  exchange->retry_task = NULL;
   GNUNET_assert (NULL == exchange->kr);
   kr = GNUNET_new (struct KeysRequest);
   kr->exchange = exchange;
-  if (GNUNET_YES == MAH_handle_is_ready (exchange) && 
!TALER_EXCHANGE_API_DISABLE_CHERRYPICKING)
+  if (GNUNET_YES ==
+      MAH_handle_is_ready (exchange) && 
!TALER_EXCHANGE_API_DISABLE_CHERRYPICKING)
   {
     char *arg;
 
@@ -1198,6 +1229,11 @@ TALER_EXCHANGE_disconnect (struct TALER_EXCHANGE_Handle 
*exchange)
     json_decref (exchange->key_data_raw);
     exchange->key_data_raw = NULL;
   }
+  if (NULL != exchange->retry_task)
+  {
+    GNUNET_SCHEDULER_cancel (exchange->retry_task);
+    exchange->retry_task = NULL;
+  }
   GNUNET_free (exchange->url);
   GNUNET_free (exchange);
 }
diff --git a/src/exchange-lib/test_exchange_api.c 
b/src/exchange-lib/test_exchange_api.c
index 7ca74a22..a96e4996 100644
--- a/src/exchange-lib/test_exchange_api.c
+++ b/src/exchange-lib/test_exchange_api.c
@@ -3821,7 +3821,8 @@ run (void *cls)
   fakebank = TALER_FAKEBANK_start (8082);
   exchange = TALER_EXCHANGE_connect (ctx,
                                      "http://localhost:8081";,
-                                     &cert_cb, is,
+                                     &cert_cb,
+                                     is,
                                      TALER_EXCHANGE_OPTION_END);
   GNUNET_assert (NULL != exchange);
   timeout_task
diff --git a/src/exchange-lib/test_exchange_api_keys_cherry_picking.c 
b/src/exchange-lib/test_exchange_api_keys_cherry_picking.c
index e5fd22a1..0dc0c540 100644
--- a/src/exchange-lib/test_exchange_api_keys_cherry_picking.c
+++ b/src/exchange-lib/test_exchange_api_keys_cherry_picking.c
@@ -597,13 +597,15 @@ run (void *cls)
   rc = GNUNET_CURL_gnunet_rc_create (ctx);
   exchange = TALER_EXCHANGE_connect (ctx,
                                      "http://localhost:8081";,
-                                     &cert_cb, is,
+                                     &cert_cb,
+                                     is,
                                      TALER_EXCHANGE_OPTION_END);
   GNUNET_assert (NULL != exchange);
   timeout_task
     = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
                                     (GNUNET_TIME_UNIT_SECONDS, 300),
-                                    &do_timeout, NULL);
+                                    &do_timeout,
+                                    NULL);
   GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
                                  is);
 }
diff --git a/src/exchange-lib/test_exchange_api_keys_cherry_picking_new.c 
b/src/exchange-lib/test_exchange_api_keys_cherry_picking_new.c
index 64c03ff9..d1fd25cf 100644
--- a/src/exchange-lib/test_exchange_api_keys_cherry_picking_new.c
+++ b/src/exchange-lib/test_exchange_api_keys_cherry_picking_new.c
@@ -63,28 +63,22 @@ run (void *cls,
      struct TALER_TESTING_Interpreter *is)
 {
   struct TALER_TESTING_Command commands[] = {
-
     /* Trigger keys reloading from disk.  */
     TALER_TESTING_cmd_signal ("signal-reaction-1",
                               is->exchanged,
                               SIGUSR1),
-
     TALER_TESTING_cmd_check_keys ("check-keys-1",
                                   1,
                                   4,
                                   is->exchange),
-
     /* 1st keyup happens at start-up */
-    TALER_TESTING_cmd_exec_keyup ("keyup-2", 
+    TALER_TESTING_cmd_exec_keyup ("keyup-2",
                                   CONFIG_FILE_EXTENDED),
-
     TALER_TESTING_cmd_exec_auditor_sign ("sign-keys-1",
                                          CONFIG_FILE),
-
     TALER_TESTING_cmd_signal ("trigger-keys-reload-1",
                               is->exchanged,
                               SIGUSR1),
-
     TALER_TESTING_cmd_check_keys ("check-keys-2",
                                   2,
 #if TALER_EXCHANGE_API_DISABLE_CHERRYPICKING
@@ -99,6 +93,7 @@ run (void *cls,
   TALER_TESTING_run (is, commands);
 }
 
+
 int
 main (int argc,
       char * const *argv)
diff --git a/src/exchange-lib/testing_api_loop.c 
b/src/exchange-lib/testing_api_loop.c
index 43d0ecc8..27611b2d 100644
--- a/src/exchange-lib/testing_api_loop.c
+++ b/src/exchange-lib/testing_api_loop.c
@@ -657,7 +657,8 @@ main_wrapper_exchange_connect (void *cls)
                  (is->exchange = TALER_EXCHANGE_connect (is->ctx,
                                                          exchange_url,
                                                          &cert_cb,
-                                                         main_ctx)));
+                                                         main_ctx,
+                                                         
TALER_EXCHANGE_OPTION_END)));
   GNUNET_free (exchange_url);
   GNUNET_CONFIGURATION_destroy (cfg);
 }

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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