[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] branch master updated: report reducer error instead of
From: |
gnunet |
Subject: |
[taler-anastasis] branch master updated: report reducer error instead of crashing |
Date: |
Mon, 04 Oct 2021 18:08:39 +0200 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository anastasis.
The following commit(s) were added to refs/heads/master by this push:
new 61ea83c report reducer error instead of crashing
61ea83c is described below
commit 61ea83cbc019db5c000baf4debf873be59528e63
Author: Florian Dold <florian@dold.me>
AuthorDate: Mon Oct 4 18:08:34 2021 +0200
report reducer error instead of crashing
---
src/reducer/anastasis_api_redux.c | 61 +++++++++++++++++++++++++++++++++++----
1 file changed, 55 insertions(+), 6 deletions(-)
diff --git a/src/reducer/anastasis_api_redux.c
b/src/reducer/anastasis_api_redux.c
index 796e60d..92801f4 100644
--- a/src/reducer/anastasis_api_redux.c
+++ b/src/reducer/anastasis_api_redux.c
@@ -1490,6 +1490,31 @@ dummy_cleanup (void *cls)
}
+/**
+ * Closure for external_redux_done.
+ */
+struct ExternalReduxCls
+{
+ ANASTASIS_ActionCallback cb;
+ void *cb_cls;
+ json_t *new_state;
+};
+
+
+/**
+ * Callback called when the redux action has been processed by
+ * the external reducer.
+ */
+static void
+external_redux_done (void *cls)
+{
+ struct ExternalReduxCls *erc = cls;
+ erc->cb (erc->cb_cls,
+ TALER_EC_NONE,
+ erc->new_state);
+}
+
+
/**
* Handle an action using an external reducer, i.e.
* by shelling out to another process.
@@ -1563,9 +1588,26 @@ redux_action_external (const char *ext_reducer,
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Wrote old state to reducer stdin.\n");
- next_state = json_loadf (reducer_stdout,
- 0,
- NULL);
+ {
+ json_error_t err;
+
+ next_state = json_loadf (reducer_stdout,
+ 0,
+ &err);
+
+ if (NULL == next_state)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "External reducer did not output valid JSON: %s:%d:%d %s\n",
+ err.source,
+ err.line,
+ err.column,
+ err.text);
+ GNUNET_assert (0 == fclose (reducer_stdout));
+ waitpid (pid, &status, 0);
+ return NULL;
+ }
+ }
/* FIXME: report error instead! */
GNUNET_assert (NULL != next_state);
@@ -1584,9 +1626,16 @@ redux_action_external (const char *ext_reducer,
/* Callback is called immediately, cleanup must never be called */
act->cleanup = &dummy_cleanup;
- cb (cb_cls,
- TALER_EC_NONE,
- next_state);
+ {
+ struct ExternalReduxCls *sched_cls = GNUNET_new (struct ExternalReduxCls);
+
+ sched_cls->cb = cb;
+ sched_cls->cb_cls = cb_cls;
+ sched_cls->new_state = next_state;
+ GNUNET_SCHEDULER_add_now (external_redux_done,
+ sched_cls);
+ }
+
return act;
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-anastasis] branch master updated: report reducer error instead of crashing,
gnunet <=