[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] branch master updated: curl: reschedule uses GNUNE
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] branch master updated: curl: reschedule uses GNUNET_CURL_perform2. |
Date: |
Wed, 17 Oct 2018 20:03:36 +0200 |
This is an automated email from the git hooks/post-receive script.
marcello-stanisci pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new 418bf5953 curl: reschedule uses GNUNET_CURL_perform2.
418bf5953 is described below
commit 418bf5953acdba2e325528d739fb115b51b7141f
Author: Marcello Stanisci <address@hidden>
AuthorDate: Wed Oct 17 20:02:35 2018 +0200
curl: reschedule uses GNUNET_CURL_perform2.
---
src/curl/curl.c | 2 +-
src/curl/curl_reschedule.c | 42 +++++++++++++++++++++++++++++++++++++++++-
src/include/gnunet_curl_lib.h | 14 +++++++++++++-
3 files changed, 55 insertions(+), 3 deletions(-)
diff --git a/src/curl/curl.c b/src/curl/curl.c
index eabe0e787..985800e64 100644
--- a/src/curl/curl.c
+++ b/src/curl/curl.c
@@ -355,7 +355,7 @@ GNUNET_CURL_job_cancel (struct GNUNET_CURL_Job *job)
* the JSON we received was malformed).
* @return NULL if downloading a JSON reply failed.
*/
-static void *
+void *
download_get_result (struct GNUNET_CURL_DownloadBuffer *db,
CURL *eh,
long *response_code)
diff --git a/src/curl/curl_reschedule.c b/src/curl/curl_reschedule.c
index ddf27fbd7..0b5b85687 100644
--- a/src/curl/curl_reschedule.c
+++ b/src/curl/curl_reschedule.c
@@ -24,6 +24,10 @@
#include "gnunet_curl_lib.h"
#include "gnunet_util_lib.h"
+extern void *
+download_get_result (struct GNUNET_CURL_DownloadBuffer *db,
+ CURL *eh,
+ long *response_code);
/**
* Closure for #GNUNET_CURL_gnunet_scheduler_reschedule().
@@ -39,10 +43,41 @@ struct GNUNET_CURL_RescheduleContext
* Context we manage.
*/
struct GNUNET_CURL_Context *ctx;
+
+ /**
+ * Parser of the raw response.
+ */
+ GNUNET_CURL_RawParser parser;
+
+ /**
+ * Deallocate the response object.
+ */
+ GNUNET_CURL_ResponseCleaner cleaner;
};
/**
+ * Initialize reschedule context; with custom response parser
+ *
+ * @param ctx context to manage
+ * @return closure for #GNUNET_CURL_gnunet_scheduler_reschedule().
+ */
+struct GNUNET_CURL_RescheduleContext *
+GNUNET_CURL_gnunet_rc_create_with_parser (struct GNUNET_CURL_Context *ctx,
+ GNUNET_CURL_RawParser rp,
+ GNUNET_CURL_ResponseCleaner rc)
+{
+ struct GNUNET_CURL_RescheduleContext *rctx;
+
+ rctx = GNUNET_new (struct GNUNET_CURL_RescheduleContext);
+ rctx->ctx = ctx;
+ rctx->parser = rp;
+ rctx->cleaner = rc;
+
+ return rctx;
+}
+
+/**
* Initialize reschedule context.
*
* @param ctx context to manage
@@ -55,6 +90,8 @@ GNUNET_CURL_gnunet_rc_create (struct GNUNET_CURL_Context *ctx)
rc = GNUNET_new (struct GNUNET_CURL_RescheduleContext);
rc->ctx = ctx;
+ rc->parser = (GNUNET_CURL_RawParser) &download_get_result;
+ rc->cleaner = (GNUNET_CURL_ResponseCleaner) &json_decref;
return rc;
}
@@ -92,7 +129,10 @@ context_task (void *cls)
struct GNUNET_TIME_Relative delay;
rc->task = NULL;
- GNUNET_CURL_perform (rc->ctx);
+
+ GNUNET_CURL_perform2 (rc->ctx,
+ rc->parser,
+ rc->cleaner);
max_fd = -1;
timeout = -1;
FD_ZERO (&read_fd_set);
diff --git a/src/include/gnunet_curl_lib.h b/src/include/gnunet_curl_lib.h
index 9bf798bca..0bad7e6c7 100644
--- a/src/include/gnunet_curl_lib.h
+++ b/src/include/gnunet_curl_lib.h
@@ -203,7 +203,7 @@ struct GNUNET_CURL_Job;
typedef void
(*GNUNET_CURL_JobCompletionCallback)(void *cls,
long response_code,
- const json_t *json);
+ const void *response);
/**
@@ -259,6 +259,18 @@ struct GNUNET_CURL_RescheduleContext *
GNUNET_CURL_gnunet_rc_create (struct GNUNET_CURL_Context *ctx);
/**
+ * Initialize reschedule context; with custom response parser
+ *
+ * @param ctx context to manage
+ * @return closure for #GNUNET_CURL_gnunet_scheduler_reschedule().
+ */
+struct GNUNET_CURL_RescheduleContext *
+GNUNET_CURL_gnunet_rc_create_with_parser (struct GNUNET_CURL_Context *ctx,
+ GNUNET_CURL_RawParser rp,
+ GNUNET_CURL_ResponseCleaner rc);
+
+
+/**
* Destroy reschedule context.
*
* @param rc context to destroy
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [gnunet] branch master updated: curl: reschedule uses GNUNET_CURL_perform2.,
gnunet <=