gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated: async state management


From: gnunet
Subject: [taler-anastasis] branch master updated: async state management
Date: Wed, 14 Oct 2020 15:27:00 +0200

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 7d43047  async state management
7d43047 is described below

commit 7d4304736d80547a409c8d5a0475d38f4450a4aa
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Wed Oct 14 15:25:19 2020 +0200

    async state management
---
 src/lib/anastasis_api_redux.c | 35 +++++++++++++++++++++++++----------
 1 file changed, 25 insertions(+), 10 deletions(-)

diff --git a/src/lib/anastasis_api_redux.c b/src/lib/anastasis_api_redux.c
index 9fad1a0..956c97d 100644
--- a/src/lib/anastasis_api_redux.c
+++ b/src/lib/anastasis_api_redux.c
@@ -268,7 +268,7 @@ conclude_select_country (struct SelectCountryHandle *sch)
   for (cr = sch->cr_head; NULL != cr; cr = cr->next)
     if (NULL != cr->co)
       return;
-  currency = json_string_value (json_object_get (cr->sch->state,
+  currency = json_string_value (json_object_get (sch->state,
                                                  "currency"));
   while (NULL != (cr = sch->cr_head))
   {
@@ -282,11 +282,11 @@ conclude_select_country (struct SelectCountryHandle *sch)
       continue;
     }
     add_config_to_state (cr,
-                         cr->sch->state);
+                         sch->state);
   }
   sch->cb (NULL,
            ANASTASIS_EC_NONE,
-           cr->sch->state);
+           sch->state);
   free_select_country (sch);
 }
 
@@ -503,7 +503,7 @@ select_continent (json_t *state,
 }
 
 
-static void
+static struct ANASTASIS_ReduxAction *
 select_country (json_t *state,
                 const json_t *arguments,
                 ANASTASIS_ActionCallback cb,
@@ -557,7 +557,7 @@ select_country (json_t *state,
     if (NULL == path)
     {
       GNUNET_break (0);
-      return;
+      return NULL;
     }
     GNUNET_asprintf (&dn,
                      "%s/share/anastasis/provider-list.json",
@@ -575,7 +575,7 @@ select_country (json_t *state,
                 error.column,
                 error.position);
     GNUNET_free (dn);
-    return;
+    return NULL;
   }
 
   // get configs from providers
@@ -625,7 +625,14 @@ select_country (json_t *state,
       }
     }
     conclude_select_country (sch);
-    // FIXME: wrap: return sch; + free_select_country();
+    {
+      struct ANASTASIS_ReduxAction *ra;
+
+      ra = GNUNET_new (struct ANASTASIS_ReduxAction);
+      ra->cleanup_cls = sch;
+      ra->cleanup = free_select_country;
+      return ra;
+    }
   }
 }
 
@@ -750,9 +757,9 @@ ANASTASIS_back_generic_decrement_ (json_t *state,
  * @param ctx Curl context
  * @param cb function to call with the result
  * @param cb_cls closure for @a cb
- * @return failure state or new state
+ * @return handle to cancel async actions, NULL if @a cb was already called
  */
-void
+struct ANASTASIS_ReduxAction *
 ANASTASIS_redux_action (const json_t *state,
                         const char *action,
                         const json_t *arguments,
@@ -848,7 +855,7 @@ ANASTASIS_redux_action (const json_t *state,
     cb (cb_cls,
         ANASTASIS_EC_INVALID, // FIXME: Define correct error code
         NULL);
-    return;
+    return NULL;
   }
   {
     json_t *new_state;
@@ -890,3 +897,11 @@ ANASTASIS_redux_action (const json_t *state,
     json_decref (new_state);
   }
 }
+
+
+void
+ANASTASIS_action_cancel (struct ANASTASIS_ReduxAction *ra)
+{
+  ra->cleanup (ra->cleanup_cls);
+  GNUNET_free (ra);
+}

-- 
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]