commit 89610bad6a8ddff83b0d09f5cbc8b596ece7ad5a
parent ae7a9ee23f51ed2d24d983022a62a64cd8f865a2
Author: Marcello Stanisci <marcello.stanisci@inria.fr>
Date: Mon, 16 Nov 2015 14:28:57 +0100
up to returning from /deposit
Diffstat:
3 files changed, 25 insertions(+), 12 deletions(-)
diff --git a/src/backend-lib/merchant_db.c b/src/backend-lib/merchant_db.c
@@ -106,10 +106,10 @@ MERCHANT_DB_initialize (PGconn *conn, int tmp)
"amount_fraction INT4 NOT NULL,"
"coin_sig BYTEA NOT NULL);"
"CREATE %1$s TABLE IF NOT EXISTS deposits ("
- "dep_perm TEXT NOT NULL,"
+ "dep_perm VARCHAR NOT NULL,"
"transaction_id INT8,"
"pending INT4 NOT NULL,"
- "mint_url TEXT NOT NULL);",
+ "mint_url VARCHAR NOT NULL);",
tmp_str);
ret = GNUNET_POSTGRES_exec (conn, sql);
(void) GNUNET_POSTGRES_exec (conn,
@@ -263,8 +263,8 @@ MERCHANT_DB_update_deposit_permission (PGconn *conn,
ExecStatusType status;
struct TALER_PQ_QueryParam params[] = {
- TALER_PQ_query_param_uint64 (&transaction_id),
TALER_PQ_query_param_uint32 (&pending),
+ TALER_PQ_query_param_uint64 (&transaction_id),
TALER_PQ_query_param_end
};
diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c
@@ -450,6 +450,17 @@ run_daemon (void *cls,
/**
+ * Kick MHD to run now, to be called after MHD_resume_connection().
+ */
+void
+trigger_daemon ()
+{
+ GNUNET_SCHEDULER_cancel (mhd_task);
+ run_daemon (NULL, NULL);
+}
+
+
+/**
* Function that queries MHD's select sets and
* starts the task waiting for them.
*
@@ -547,7 +558,7 @@ run (void *cls, char *const *args, const char *cfgfile,
EXITIF (NULL ==
(db_conn = MERCHANT_DB_connect (config)));
EXITIF (GNUNET_OK !=
- MERCHANT_DB_initialize (db_conn, GNUNET_YES));
+ MERCHANT_DB_initialize (db_conn, dry));
EXITIF (GNUNET_SYSERR ==
GNUNET_CONFIGURATION_get_value_number (config,
"merchant",
diff --git a/src/backend/taler-merchant-httpd_pay.c b/src/backend/taler-merchant-httpd_pay.c
@@ -144,15 +144,19 @@ deposit_cb (void *cls, unsigned int http_status, json_t *proof)
/* just return if there is at least one coin to be still
confirmed */
if (!dccls->dc[i].ackd)
+ {
+ printf ("still vacant coins\n");
return;
+ }
}
printf ("All /deposit(s) ack'd\n");
MHD_resume_connection (dccls->connection);
- TMH_RESPONSE_reply_json_pack (dccls->connection,
- MHD_HTTP_OK,
- "{s:s}",
- "result", "all conins ack'd (and connection resumed)");
+ i = TMH_RESPONSE_reply_json_pack (dccls->connection,
+ MHD_HTTP_OK,
+ "{s:s}",
+ "result", "all conins ack'd (and connection resumed)");
+ printf ("mhd res %d\n", i);
/* TODO at this point, any coin has been confirmed by the mint. So
check for errors .. */
@@ -179,7 +183,6 @@ MH_handler_pay (struct TMH_RequestHandler *rh,
const char *upload_data,
size_t *upload_data_size)
{
-
json_t *root;
json_t *coins;
char *chosen_mint;
@@ -190,7 +193,6 @@ MH_handler_pay (struct TMH_RequestHandler *rh,
unsigned int coins_cnt;
uint64_t transaction_id;
int res;
-
struct TALER_MINT_DepositHandle *dh;
struct TALER_Amount max_fee;
struct TALER_Amount acc_fee;
@@ -205,7 +207,6 @@ MH_handler_pay (struct TMH_RequestHandler *rh,
struct TALER_DenominationSignature ub_sig;
struct TALER_CoinSpendSignatureP coin_sig;
struct GNUNET_HashCode h_contract;
-
struct MERCHANT_DepositConfirmation *dc;
struct MERCHANT_DepositConfirmationCls *dccls;
@@ -411,7 +412,7 @@ MH_handler_pay (struct TMH_RequestHandler *rh,
dccls); /*may be destroyed by the time the cb gets called..*/
if (NULL == dh)
{
- MHD_suspend_connection (connection);
+ MHD_resume_connection (connection);
return TMH_RESPONSE_reply_json_pack (connection,
MHD_HTTP_SERVICE_UNAVAILABLE,
"{s:s, s:i}",
@@ -423,6 +424,7 @@ MH_handler_pay (struct TMH_RequestHandler *rh,
printf ("poller task: %p\n", poller_task);
GNUNET_SCHEDULER_cancel (poller_task);
GNUNET_SCHEDULER_add_now (context_task, mints[mint_index].ctx);
+ return MHD_YES;
/* 4 Return response code: success, or whatever data the
mint sent back regarding some bad coin */