summaryrefslogtreecommitdiff
path: root/src/backend/taler-merchant-httpd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/taler-merchant-httpd.c')
-rw-r--r--src/backend/taler-merchant-httpd.c44
1 files changed, 19 insertions, 25 deletions
diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c
index a6bce84d..1f59eec2 100644
--- a/src/backend/taler-merchant-httpd.c
+++ b/src/backend/taler-merchant-httpd.c
@@ -829,14 +829,8 @@ run_daemon (void *cls)
}
-/**
- * Kick MHD to run now, to be called after MHD_resume_connection().
- * Basically, we need to explicitly resume MHD's event loop whenever
- * we made progress serving a request. This function re-schedules
- * the task processing MHD's activities to run immediately.
- */
void
-TMH_trigger_daemon ()
+TMH_trigger_daemon (void)
{
if (NULL != mhd_task)
{
@@ -852,8 +846,10 @@ TMH_trigger_daemon ()
/**
- * Function that queries MHD's select sets and
- * starts the task waiting for them.
+ * Function that queries MHD's select sets and starts the task waiting for
+ * them.
+ *
+ * @return task handle for the MHD task.
*/
static struct GNUNET_SCHEDULER_Task *
prepare_daemon (void)
@@ -902,12 +898,6 @@ prepare_daemon (void)
}
-/**
- * Lookup a merchant instance by its instance ID.
- *
- * @param instance_id identifier of the instance to resolve
- * @return NULL if that instance is unknown to us
- */
struct TMH_MerchantInstance *
TMH_lookup_instance (const char *instance_id)
{
@@ -1199,6 +1189,7 @@ url_handler (void *cls,
{
.url_prefix = "/",
.method = MHD_HTTP_METHOD_DELETE,
+ .allow_deleted_instance = true,
.handler = &TMH_private_delete_instances_ID
},
/* PATCH /instances/$ID/: */
@@ -1206,6 +1197,7 @@ url_handler (void *cls,
.url_prefix = "/",
.method = MHD_HTTP_METHOD_PATCH,
.handler = &TMH_private_patch_instances_ID,
+ .allow_deleted_instance = true,
/* allow instance data of up to 8 MB, that should be plenty;
note that exceeding #GNUNET_MAX_MALLOC_CHECKED (40 MB)
would require further changes to the allocation logic
@@ -1641,11 +1633,6 @@ url_handler (void *cls,
slash - istart);
hc->instance = TMH_lookup_instance (instance_id);
GNUNET_free (instance_id);
- if (NULL == hc->instance)
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_NOT_FOUND,
- TALER_EC_GENERIC_ENDPOINT_UNKNOWN,
- url);
if (NULL == slash)
url = "";
else
@@ -1889,12 +1876,17 @@ url_handler (void *cls,
} /* if (use_private) */
- if ( (NULL == hc->instance) &&
- (! hc->rh->skip_instance) )
+ if ( ( (NULL == hc->instance) &&
+ (! hc->rh->skip_instance) ) ||
+ ( (! hc->rh->skip_instance) &&
+ (hc->instance->deleted) &&
+ (! hc->rh->allow_deleted_instance) ) )
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_NOT_FOUND,
TALER_EC_MERCHANT_GENERIC_INSTANCE_UNKNOWN,
url);
+
+
hc->has_body = ( (0 == strcasecmp (method,
MHD_HTTP_METHOD_POST)) ||
(0 == strcasecmp (method,
@@ -1964,7 +1956,6 @@ add_instance_cb (void *cls,
struct TMH_MerchantInstance *mi;
(void) cls;
- GNUNET_assert (NULL != merchant_priv);
mi = GNUNET_new (struct TMH_MerchantInstance);
mi->settings = *is;
mi->auth = *ias;
@@ -1972,7 +1963,10 @@ add_instance_cb (void *cls,
mi->settings.name = GNUNET_strdup (mi->settings.name);
mi->settings.address = json_incref (mi->settings.address);
mi->settings.jurisdiction = json_incref (mi->settings.jurisdiction);
- mi->merchant_priv = *merchant_priv;
+ if (NULL != merchant_priv)
+ mi->merchant_priv = *merchant_priv;
+ else
+ mi->deleted = true;
mi->merchant_pub = *merchant_pub;
for (unsigned int i = 0; i<accounts_length; i++)
{
@@ -2110,7 +2104,7 @@ run (void *cls,
enum GNUNET_DB_QueryStatus qs;
qs = TMH_db->lookup_instances (TMH_db->cls,
- true,
+ false,
&add_instance_cb,
NULL);
if (0 > qs)