summaryrefslogtreecommitdiff
path: root/src/exchange/taler-exchange-transfer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/exchange/taler-exchange-transfer.c')
-rw-r--r--src/exchange/taler-exchange-transfer.c61
1 files changed, 32 insertions, 29 deletions
diff --git a/src/exchange/taler-exchange-transfer.c b/src/exchange/taler-exchange-transfer.c
index c2ad59ae5..9724b41fc 100644
--- a/src/exchange/taler-exchange-transfer.c
+++ b/src/exchange/taler-exchange-transfer.c
@@ -201,7 +201,7 @@ static unsigned int shard_size = DEFAULT_BATCH_SIZE;
/**
* How many workers should we plan our scheduling with?
*/
-static unsigned int max_workers = 16;
+static unsigned int max_workers = 0;
/**
@@ -264,7 +264,7 @@ shutdown_task (void *cls)
/**
- * Parse the configuration for wirewatch.
+ * Parse the configuration for taler-exchange-transfer.
*
* @return #GNUNET_OK on success
*/
@@ -338,6 +338,15 @@ static void
run_transfers (void *cls);
+static void
+run_transfers_delayed (void *cls)
+{
+ (void) cls;
+ shard->shard_start_time = GNUNET_TIME_absolute_get ();
+ run_transfers (NULL);
+}
+
+
/**
* Select shard to process.
*
@@ -397,25 +406,17 @@ batch_done (void)
* except for irrecoverable errors.
*
* @param cls `struct WirePrepareData` we are working on
- * @param http_status_code #MHD_HTTP_OK on success
- * @param ec taler error code
- * @param row_id unique ID of the wire transfer in the bank's records
- * @param wire_timestamp when did the transfer happen
+ * @param tr transfer response
*/
static void
wire_confirm_cb (void *cls,
- unsigned int http_status_code,
- enum TALER_ErrorCode ec,
- uint64_t row_id,
- struct GNUNET_TIME_Absolute wire_timestamp)
+ const struct TALER_BANK_TransferResponse *tr)
{
struct WirePrepareData *wpd = cls;
enum GNUNET_DB_QueryStatus qs;
- (void) row_id;
- (void) wire_timestamp;
wpd->eh = NULL;
- switch (http_status_code)
+ switch (tr->http_status)
{
case MHD_HTTP_OK:
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -426,11 +427,12 @@ wire_confirm_cb (void *cls,
/* continued below */
break;
case MHD_HTTP_NOT_FOUND:
+ case MHD_HTTP_CONFLICT:
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Wire transaction %llu failed: %u/%d\n",
(unsigned long long) wpd->row_id,
- http_status_code,
- ec);
+ tr->http_status,
+ tr->ec);
qs = db_plugin->wire_prepare_data_mark_failed (db_plugin->cls,
wpd->row_id);
/* continued below */
@@ -447,7 +449,7 @@ wire_confirm_cb (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Wire transfer %llu failed (%u), trying again\n",
(unsigned long long) wpd->row_id,
- http_status_code);
+ tr->http_status);
wpd->eh = TALER_BANK_transfer (ctx,
wpd->wa->auth,
&wpd[1],
@@ -459,8 +461,8 @@ wire_confirm_cb (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Wire transaction %llu failed: %u/%d\n",
(unsigned long long) wpd->row_id,
- http_status_code,
- ec);
+ tr->http_status,
+ tr->ec);
cleanup_wpd ();
db_plugin->rollback (db_plugin->cls);
global_ret = EXIT_FAILURE;
@@ -470,8 +472,8 @@ wire_confirm_cb (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Wire transfer %llu failed: %u/%d\n",
(unsigned long long) wpd->row_id,
- http_status_code,
- ec);
+ tr->http_status,
+ tr->ec);
db_plugin->rollback (db_plugin->cls);
cleanup_wpd ();
global_ret = EXIT_FAILURE;
@@ -554,9 +556,9 @@ wire_prepare_cb (void *cls,
}
wpd = GNUNET_malloc (sizeof (struct WirePrepareData)
+ buf_size);
- memcpy (&wpd[1],
- buf,
- buf_size);
+ GNUNET_memcpy (&wpd[1],
+ buf,
+ buf_size);
wpd->buf_size = buf_size;
wpd->row_id = rowid;
GNUNET_CONTAINER_DLL_insert (wpd_head,
@@ -573,7 +575,7 @@ wire_prepare_cb (void *cls,
GNUNET_break (0);
cleanup_wpd ();
db_plugin->rollback (db_plugin->cls);
- global_ret = EXIT_NOTCONFIGURED;
+ global_ret = EXIT_NO_RESTART;
GNUNET_SCHEDULER_shutdown ();
return;
}
@@ -642,7 +644,8 @@ run_transfers (void *cls)
/* normal case */
break;
}
- shard_delay = GNUNET_TIME_absolute_get_duration (shard->shard_start_time);
+ shard_delay = GNUNET_TIME_absolute_get_duration (
+ shard->shard_start_time);
GNUNET_free (shard);
GNUNET_assert (NULL == task);
task = GNUNET_SCHEDULER_add_now (&select_shard,
@@ -705,11 +708,11 @@ run_transfers (void *cls)
}
else
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"No more pending wire transfers, going idle\n");
GNUNET_assert (NULL == task);
task = GNUNET_SCHEDULER_add_delayed (transfer_idle_sleep_interval,
- &run_transfers,
+ &run_transfers_delayed,
NULL);
}
return;
@@ -776,8 +779,8 @@ select_shard (void *cls)
GNUNET_assert (NULL == task);
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Serialization failure, trying again in %s!\n",
- GNUNET_STRINGS_relative_time_to_string (serialization_delay,
- GNUNET_YES));
+ GNUNET_TIME_relative2s (serialization_delay,
+ true));
task = GNUNET_SCHEDULER_add_delayed (serialization_delay,
&select_shard,
NULL);