aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-12-12 11:34:57 +0100
committerChristian Grothoff <christian@grothoff.org>2020-12-12 11:34:57 +0100
commit09abf5e7e08c749c0a8904ba651e0357404e8aa9 (patch)
tree12cd3c8779a80f59d25e4a4f7f0e8158238938c2
parent2a3de6555abde9a7159187e01ee140192b155f25 (diff)
integrate new REST calls, add timeout to helper invocations
-rw-r--r--src/exchange/taler-exchange-httpd.c5
-rw-r--r--src/exchange/taler-exchange-httpd_keys.c2
-rw-r--r--src/util/crypto_helper_denom.c30
-rw-r--r--src/util/crypto_helper_esign.c29
4 files changed, 61 insertions, 5 deletions
diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c
index 0eb4de59a..d9c565406 100644
--- a/src/exchange/taler-exchange-httpd.c
+++ b/src/exchange/taler-exchange-httpd.c
@@ -606,8 +606,6 @@ handle_post_management (const struct TEH_RequestHandler *rh,
&exchange_pub,
root);
}
-#if FIXME
- /* not yet implemented! */
if (0 == strcmp (args[0],
"keys"))
{
@@ -619,7 +617,6 @@ handle_post_management (const struct TEH_RequestHandler *rh,
return TEH_handler_management_post_keys (connection,
root);
}
-#endif
if (0 == strcmp (args[0],
"wire"))
{
@@ -808,7 +805,7 @@ handle_mhd_request (void *cls,
{
.url = "keys",
.method = MHD_HTTP_METHOD_GET,
- .handler.get = &TEH_handler_keys,
+ .handler.get = &TEH_handler_keys, // FIXME => TEH_keys_get_handler
},
/* Requests for wiring information */
{
diff --git a/src/exchange/taler-exchange-httpd_keys.c b/src/exchange/taler-exchange-httpd_keys.c
index 88ab2e309..6e778677a 100644
--- a/src/exchange/taler-exchange-httpd_keys.c
+++ b/src/exchange/taler-exchange-httpd_keys.c
@@ -1700,7 +1700,7 @@ krd_search_comparator (const void *key,
MHD_RESULT
-TEH_handler_keys_NEW (const struct TEH_RequestHandler *rh,
+TEH_keys_get_handler (const struct TEH_RequestHandler *rh,
struct MHD_Connection *connection,
const char *const args[])
{
diff --git a/src/util/crypto_helper_denom.c b/src/util/crypto_helper_denom.c
index fa8a820b5..81a4e8fd7 100644
--- a/src/util/crypto_helper_denom.c
+++ b/src/util/crypto_helper_denom.c
@@ -22,6 +22,7 @@
#include "taler_util.h"
#include "taler_signatures.h"
#include "taler-helper-crypto-rsa.h"
+#include <poll.h>
struct TALER_CRYPTO_DenominationHelper
@@ -465,6 +466,35 @@ TALER_CRYPTO_helper_denom_sign (
const struct GNUNET_MessageHeader *hdr
= (const struct GNUNET_MessageHeader *) buf;
+ {
+ /* wait for reply with 5s timeout */
+ struct pollfd pfd = {
+ .fd = dh->sock,
+ .events = POLLIN
+ };
+ sigset_t sigmask;
+ struct timespec ts = {
+ .tv_sec = 5
+ };
+
+ GNUNET_assert (0 == sigemptyset (&sigmask));
+ GNUNET_assert (0 == sigaddset (&sigmask, SIGTERM));
+ GNUNET_assert (0 == sigaddset (&sigmask, SIGHUP));
+ ret = ppoll (&pfd,
+ 1,
+ &ts,
+ &sigmask);
+ if ( (-1 == ret) &&
+ (EINTR != errno) )
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
+ "ppoll");
+ if (0 >= ret)
+ {
+ do_disconnect (dh);
+ *ec = TALER_EC_GENERIC_TIMEOUT;
+ return ds;
+ }
+ }
ret = recv (dh->sock,
buf,
sizeof (buf),
diff --git a/src/util/crypto_helper_esign.c b/src/util/crypto_helper_esign.c
index fde7f48ee..39130e04f 100644
--- a/src/util/crypto_helper_esign.c
+++ b/src/util/crypto_helper_esign.c
@@ -22,6 +22,7 @@
#include "taler_util.h"
#include "taler_signatures.h"
#include "taler-helper-crypto-eddsa.h"
+#include <poll.h>
struct TALER_CRYPTO_ExchangeSignHelper
@@ -421,6 +422,34 @@ TALER_CRYPTO_helper_esign_sign_ (
const struct GNUNET_MessageHeader *hdr
= (const struct GNUNET_MessageHeader *) buf;
+ {
+ /* wait for reply with 5s timeout */
+ struct pollfd pfd = {
+ .fd = esh->sock,
+ .events = POLLIN
+ };
+ sigset_t sigmask;
+ struct timespec ts = {
+ .tv_sec = 5
+ };
+
+ GNUNET_assert (0 == sigemptyset (&sigmask));
+ GNUNET_assert (0 == sigaddset (&sigmask, SIGTERM));
+ GNUNET_assert (0 == sigaddset (&sigmask, SIGHUP));
+ ret = ppoll (&pfd,
+ 1,
+ &ts,
+ &sigmask);
+ if ( (-1 == ret) &&
+ (EINTR != errno) )
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
+ "ppoll");
+ if (0 >= ret)
+ {
+ do_disconnect (esh);
+ return TALER_EC_GENERIC_TIMEOUT;
+ }
+ }
ret = recv (esh->sock,
buf,
sizeof (buf),