integrate new REST calls, add timeout to helper invocations

This commit is contained in:
Christian Grothoff 2020-12-12 11:34:57 +01:00
parent 2a3de6555a
commit 09abf5e7e0
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
4 changed files with 61 additions and 5 deletions

View File

@ -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 */
{

View File

@ -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[])
{

View File

@ -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),

View File

@ -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),