diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-05-02 08:24:21 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-05-02 08:24:21 +0200 |
commit | 5fd6a25c6d88c62af9fda04f92b954bb1dbb4436 (patch) | |
tree | 2abd2ad6c21ed7134010e750eff4921bb84bfc2f /src/exchange-lib | |
parent | ad45e5ab7a679e493d6c28910b2d01b73e0d7e57 (diff) |
code simplification via new extended libgnunetcurl API
Diffstat (limited to 'src/exchange-lib')
-rw-r--r-- | src/exchange-lib/test_exchange_api.c | 92 |
1 files changed, 10 insertions, 82 deletions
diff --git a/src/exchange-lib/test_exchange_api.c b/src/exchange-lib/test_exchange_api.c index 1ab09c9c4..e48c59b2a 100644 --- a/src/exchange-lib/test_exchange_api.c +++ b/src/exchange-lib/test_exchange_api.c @@ -48,14 +48,14 @@ static struct GNUNET_CURL_Context *ctx; static struct TALER_EXCHANGE_Handle *exchange; /** - * Task run on timeout. + * Context for running the CURL event loop. */ -static struct GNUNET_SCHEDULER_Task *timeout_task; +static struct GNUNET_CURL_RescheduleContext *rc; /** - * Task that runs the main event loop. + * Task run on timeout. */ -static struct GNUNET_SCHEDULER_Task *ctx_task; +static struct GNUNET_SCHEDULER_Task *timeout_task; /** * Result of the testcases, #GNUNET_OK on success @@ -2147,10 +2147,10 @@ do_shutdown (void *cls) GNUNET_CURL_fini (ctx); ctx = NULL; } - if (NULL != ctx_task) + if (NULL != rc) { - GNUNET_SCHEDULER_cancel (ctx_task); - ctx_task = NULL; + GNUNET_CURL_gnunet_rc_destroy (rc); + rc = NULL; } if (NULL != timeout_task) { @@ -2195,77 +2195,6 @@ cert_cb (void *cls, /** - * Task that runs the context's event loop with the GNUnet scheduler. - * - * @param cls unused - */ -static void -context_task (void *cls) -{ - long timeout; - int max_fd; - fd_set read_fd_set; - fd_set write_fd_set; - fd_set except_fd_set; - struct GNUNET_NETWORK_FDSet *rs; - struct GNUNET_NETWORK_FDSet *ws; - struct GNUNET_TIME_Relative delay; - - ctx_task = NULL; - GNUNET_CURL_perform (ctx); - max_fd = -1; - timeout = -1; - FD_ZERO (&read_fd_set); - FD_ZERO (&write_fd_set); - FD_ZERO (&except_fd_set); - GNUNET_CURL_get_select_info (ctx, - &read_fd_set, - &write_fd_set, - &except_fd_set, - &max_fd, - &timeout); - if (timeout >= 0) - delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, - timeout); - else - delay = GNUNET_TIME_UNIT_FOREVER_REL; - rs = GNUNET_NETWORK_fdset_create (); - GNUNET_NETWORK_fdset_copy_native (rs, - &read_fd_set, - max_fd + 1); - ws = GNUNET_NETWORK_fdset_create (); - GNUNET_NETWORK_fdset_copy_native (ws, - &write_fd_set, - max_fd + 1); - ctx_task = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, - delay, - rs, - ws, - &context_task, - cls); - GNUNET_NETWORK_fdset_destroy (rs); - GNUNET_NETWORK_fdset_destroy (ws); -} - - -/** - * Run the context task, the working set has changed. - * - * @param cls NULL - */ -static void -trigger_context_task (void *cls) -{ - if (NULL == ctx) - return; - if (NULL != ctx_task) - GNUNET_SCHEDULER_cancel (ctx_task); - ctx_task = GNUNET_SCHEDULER_add_now (&context_task, - NULL); -} - - -/** * Main function that will be run by the scheduler. * * @param cls closure @@ -2510,11 +2439,10 @@ run (void *cls) is = GNUNET_new (struct InterpreterState); is->commands = commands; - ctx = GNUNET_CURL_init (&trigger_context_task, - NULL); + ctx = GNUNET_CURL_init (&GNUNET_CURL_gnunet_scheduler_reschedule, + &rc); + rc = GNUNET_CURL_gnunet_rc_create (ctx); GNUNET_assert (NULL != ctx); - ctx_task = GNUNET_SCHEDULER_add_now (&context_task, - ctx); exchange = TALER_EXCHANGE_connect (ctx, "http://localhost:8081", &cert_cb, is, |