diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-04-17 16:22:49 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-04-17 16:22:49 +0200 |
commit | 921344236b01e5e6c39eb21d3602eb4bf31b90f3 (patch) | |
tree | 153020d7f2ba487748e8813773ef6ae264cf300f | |
parent | 87f857957cc8b2241afa150830d9822a419ed8c4 (diff) | |
download | merchant-921344236b01e5e6c39eb21d3602eb4bf31b90f3.tar.gz merchant-921344236b01e5e6c39eb21d3602eb4bf31b90f3.tar.bz2 merchant-921344236b01e5e6c39eb21d3602eb4bf31b90f3.zip |
adding logging to aid diagnosis of #4433
m--------- | examples/blog/web-common | 0 | ||||
m--------- | examples/shop/web-common | 0 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd.c | 24 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd.h | 9 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_pay.c | 61 |
5 files changed, 63 insertions, 31 deletions
diff --git a/examples/blog/web-common b/examples/blog/web-common -Subproject eb164f4a0ba56bb1232052b5cde19014fca70ed +Subproject 026ef2476676ef00b6c2a0cec135a8e64024ee5 diff --git a/examples/shop/web-common b/examples/shop/web-common -Subproject eb164f4a0ba56bb1232052b5cde19014fca70ed +Subproject 026ef2476676ef00b6c2a0cec135a8e64024ee5 diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c index 23627ff1..01dea3fd 100644 --- a/src/backend/taler-merchant-httpd.c +++ b/src/backend/taler-merchant-httpd.c @@ -194,8 +194,10 @@ url_handler (void *cls, "<html><title>404: not found</title></html>", 0, &TMH_MHD_handler_static_response, MHD_HTTP_NOT_FOUND }; + struct TM_HandlerContext *hc; struct TMH_RequestHandler *rh; unsigned int i; + int ret; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Handling request for URL `%s'\n", @@ -208,11 +210,17 @@ url_handler (void *cls, ( (NULL == rh->method) || (0 == strcasecmp (method, rh->method)) ) ) - return rh->handler (rh, - connection, - con_cls, - upload_data, - upload_data_size); + { + ret = rh->handler (rh, + connection, + con_cls, + upload_data, + upload_data_size); + hc = *con_cls; + if (NULL != hc) + hc->rh = rh; + return ret; + } } return TMH_MHD_handler_static_response (&h404, connection, @@ -278,10 +286,14 @@ handle_mhd_completion_callback (void *cls, void **con_cls, enum MHD_RequestTerminationCode toe) { - struct TM_HandlerContext *hc = *con_cls; /* 'hc' is also a 'struct PayContext' */ + struct TM_HandlerContext *hc = *con_cls; if (NULL == hc) return; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Finished handling request for `%s' with status %d\n", + hc->rh->url, + (int) toe); hc->cc (hc); *con_cls = NULL; } diff --git a/src/backend/taler-merchant-httpd.h b/src/backend/taler-merchant-httpd.h index d8bc464f..3594c01f 100644 --- a/src/backend/taler-merchant-httpd.h +++ b/src/backend/taler-merchant-httpd.h @@ -123,6 +123,11 @@ struct TM_HandlerContext */ TM_ContextCleanup cc; + /** + * Which request handler is handling this request? + */ + const struct TMH_RequestHandler *rh; + }; @@ -163,12 +168,12 @@ extern struct GNUNET_CRYPTO_EddsaPrivateKey *privkey; /** * Our public key, corresponds to #privkey. - */ + */ extern struct TALER_MerchantPublicKeyP pubkey; /** * Handle to the database backend. - */ + */ extern struct TALER_MERCHANTDB_Plugin *db; /** diff --git a/src/backend/taler-merchant-httpd_pay.c b/src/backend/taler-merchant-httpd_pay.c index 36fa439d..7dc93db2 100644 --- a/src/backend/taler-merchant-httpd_pay.c +++ b/src/backend/taler-merchant-httpd_pay.c @@ -226,6 +226,9 @@ resume_pay_with_response (struct PayContext *pc, { pc->response_code = response_code; pc->response = response; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Resuming /pay handling as exchange interaction is done (%u)\n", + response_code); MHD_resume_connection (pc->connection); TMH_trigger_daemon (); /* we resumed, kick MHD */ } @@ -241,6 +244,8 @@ abort_deposit (struct PayContext *pc) { unsigned int i; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Aborting pending /deposit operations\n"); for (i=0;i<pc->coins_cnt;i++) { struct MERCHANT_DepositConfirmation *dci = &pc->dc[i]; @@ -379,8 +384,8 @@ pay_context_cleanup (struct TM_HandlerContext *hc) */ static void process_pay_with_exchange (void *cls, - struct TALER_EXCHANGE_Handle *mh, - int exchange_trusted) + struct TALER_EXCHANGE_Handle *mh, + int exchange_trusted) { struct PayContext *pc = cls; struct TALER_Amount acc_fee; @@ -533,6 +538,8 @@ process_pay_with_exchange (void *cls, } } + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Exchange and fee structure OK. Initiating deposit operation for coins\n"); /* Initiate /deposit operation for all coins */ for (i=0;i<pc->coins_cnt;i++) { @@ -541,20 +548,20 @@ process_pay_with_exchange (void *cls, GNUNET_assert (NULL != j_wire); dc->dh = TALER_EXCHANGE_deposit (mh, - &dc->percoin_amount, - pc->edate, - j_wire, - &pc->h_contract, - &dc->coin_pub, - &dc->ub_sig, - &dc->denom, - pc->timestamp, - pc->transaction_id, - &pubkey, - pc->refund_deadline, - &dc->coin_sig, - &deposit_cb, - dc); + &dc->percoin_amount, + pc->edate, + j_wire, + &pc->h_contract, + &dc->coin_pub, + &dc->ub_sig, + &dc->denom, + pc->timestamp, + pc->transaction_id, + &pubkey, + pc->refund_deadline, + &dc->coin_sig, + &deposit_cb, + dc); if (NULL == dc->dh) { /* Signature was invalid. If the exchange was unavailable, @@ -612,7 +619,10 @@ MH_handler_pay (struct TMH_RequestHandler *rh, { /* We are *done* processing the request, just queue the response (!) */ if (UINT_MAX == pc->response_code) + { + GNUNET_break (0); return MHD_NO; /* hard error */ + } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Queueing response for /pay.\n"); res = MHD_queue_response (connection, @@ -632,7 +642,10 @@ MH_handler_pay (struct TMH_RequestHandler *rh, upload_data_size, &root); if (GNUNET_SYSERR == res) + { + GNUNET_break (0); return MHD_NO; /* error parsing JSON */ + } if ((GNUNET_NO == res) || (NULL == root)) return MHD_YES; /* the POST's body has to be further fetched */ @@ -663,6 +676,7 @@ MH_handler_pay (struct TMH_RequestHandler *rh, if (GNUNET_YES != res) { json_decref (root); + GNUNET_break (0); return (GNUNET_NO == res) ? MHD_YES : MHD_NO; } pc->chosen_exchange = GNUNET_strdup (chosen_exchange); @@ -709,6 +723,7 @@ MH_handler_pay (struct TMH_RequestHandler *rh, if (GNUNET_YES != res) { json_decref (root); + GNUNET_break (0); return (GNUNET_NO == res) ? MHD_YES : MHD_NO; } } @@ -725,11 +740,6 @@ MH_handler_pay (struct TMH_RequestHandler *rh, pc->dc = GNUNET_new_array (pc->coins_cnt, struct MERCHANT_DepositConfirmation); - { - char *s = json_dumps (coins, JSON_INDENT(2)); - free (s); - } - json_array_foreach (coins, coins_index, coin) { struct MERCHANT_DepositConfirmation *dc = &pc->dc[coins_index]; @@ -748,6 +758,7 @@ MH_handler_pay (struct TMH_RequestHandler *rh, if (GNUNET_YES != res) { json_decref (root); + GNUNET_break (0); return (GNUNET_NO == res) ? MHD_YES : MHD_NO; } @@ -789,14 +800,18 @@ MH_handler_pay (struct TMH_RequestHandler *rh, /* Find the responsible exchange, this may take a while... */ pc->pending = pc->coins_cnt; pc->fo = TMH_EXCHANGES_find_exchange (pc->chosen_exchange, - &process_pay_with_exchange, - pc); + &process_pay_with_exchange, + pc); /* ... so we suspend connection until the last coin has been ack'd or until we have encountered a hard error. Eventually, we will resume the connection and send back a response using #resume_pay_with_response(). */ + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Suspending /pay handling while working with the exchange\n"); MHD_suspend_connection (connection); json_decref (root); return MHD_YES; } + +/* end of taler-merchant-httpd_pay.c */ |