From 450bdaeaf612aa7717c23390239804bb28b7870f Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 2 May 2016 00:23:27 +0000 Subject: API update to fix #4479 --- po/POTFILES.in | 1 - src/curl/curl.c | 18 +++++++++++++++++- src/include/gnunet_curl_lib.h | 17 ++++++++++++++++- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/po/POTFILES.in b/po/POTFILES.in index 06d180231..ad6c57a90 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -429,7 +429,6 @@ src/util/crypto_random.c src/util/crypto_rsa.c src/util/crypto_symmetric.c src/util/disk.c -src/util/disk_iterator.c src/util/getopt.c src/util/getopt_helpers.c src/util/gnunet-config.c diff --git a/src/curl/curl.c b/src/curl/curl.c index 92761989f..ac9eeb4fc 100644 --- a/src/curl/curl.c +++ b/src/curl/curl.c @@ -159,6 +159,16 @@ struct GNUNET_CURL_Context */ struct curl_slist *json_header; + /** + * Function we need to call whenever the event loop's + * socket set changed. + */ + GNUNET_CURL_RescheduleCallback cb; + + /** + * Closure for @e cb. + */ + void *cb_cls; }; @@ -166,10 +176,13 @@ struct GNUNET_CURL_Context * Initialise this library. This function should be called before using any of * the following functions. * + * @param cb function to call when rescheduling is required + * @param cb_cls closure for @a cb * @return library context */ struct GNUNET_CURL_Context * -GNUNET_CURL_init () +GNUNET_CURL_init (GNUNET_CURL_RescheduleCallback cb, + void *cb_cls) { struct GNUNET_CURL_Context *ctx; CURLM *multi; @@ -194,6 +207,8 @@ GNUNET_CURL_init () return NULL; } ctx = GNUNET_new (struct GNUNET_CURL_Context); + ctx->cb = cb; + ctx->cb_cls = cb_cls; ctx->multi = multi; ctx->share = share; GNUNET_assert (NULL != (ctx->json_header = @@ -316,6 +331,7 @@ GNUNET_CURL_job_add (struct GNUNET_CURL_Context *ctx, GNUNET_CONTAINER_DLL_insert (ctx->jobs_head, ctx->jobs_tail, job); + ctx->cb (ctx->cb_cls); return job; } diff --git a/src/include/gnunet_curl_lib.h b/src/include/gnunet_curl_lib.h index faa7abbed..c57b9ed3b 100644 --- a/src/include/gnunet_curl_lib.h +++ b/src/include/gnunet_curl_lib.h @@ -37,14 +37,29 @@ #include "gnunet_util_lib.h" +/** + * Function called by the context to ask for the event loop to be + * rescheduled, that is the application should call + * #GNUNET_CURL_get_select_info() as the set of sockets we care about + * just changed. + * + * @param cls closure + */ +typedef void +(*GNUNET_CURL_RescheduleCallback)(void *cls); + + /** * Initialise this library. This function should be called before using any of * the following functions. * + * @param cb function to call when rescheduling is required + * @param cb_cls closure for @a cb * @return library context */ struct GNUNET_CURL_Context * -GNUNET_CURL_init (void); +GNUNET_CURL_init (GNUNET_CURL_RescheduleCallback cb, + void *cb_cls); /** -- cgit v1.2.3