aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcello Stanisci <stanisci.m@gmail.com>2018-10-17 20:02:35 +0200
committerMarcello Stanisci <stanisci.m@gmail.com>2018-10-17 20:02:35 +0200
commit418bf5953acdba2e325528d739fb115b51b7141f (patch)
tree7fea556ead0f84b870b382bec1577a76f15b9d00 /src
parent25b9d3dfa6fb538627e6cd8ed4b5741e18b752d9 (diff)
downloadgnunet-418bf5953acdba2e325528d739fb115b51b7141f.tar.gz
gnunet-418bf5953acdba2e325528d739fb115b51b7141f.zip
curl: reschedule uses GNUNET_CURL_perform2.
Diffstat (limited to 'src')
-rw-r--r--src/curl/curl.c2
-rw-r--r--src/curl/curl_reschedule.c42
-rw-r--r--src/include/gnunet_curl_lib.h14
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)
355 * the JSON we received was malformed). 355 * the JSON we received was malformed).
356 * @return NULL if downloading a JSON reply failed. 356 * @return NULL if downloading a JSON reply failed.
357 */ 357 */
358static void * 358void *
359download_get_result (struct GNUNET_CURL_DownloadBuffer *db, 359download_get_result (struct GNUNET_CURL_DownloadBuffer *db,
360 CURL *eh, 360 CURL *eh,
361 long *response_code) 361 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 @@
24#include "gnunet_curl_lib.h" 24#include "gnunet_curl_lib.h"
25#include "gnunet_util_lib.h" 25#include "gnunet_util_lib.h"
26 26
27extern void *
28download_get_result (struct GNUNET_CURL_DownloadBuffer *db,
29 CURL *eh,
30 long *response_code);
27 31
28/** 32/**
29 * Closure for #GNUNET_CURL_gnunet_scheduler_reschedule(). 33 * Closure for #GNUNET_CURL_gnunet_scheduler_reschedule().
@@ -39,10 +43,41 @@ struct GNUNET_CURL_RescheduleContext
39 * Context we manage. 43 * Context we manage.
40 */ 44 */
41 struct GNUNET_CURL_Context *ctx; 45 struct GNUNET_CURL_Context *ctx;
46
47 /**
48 * Parser of the raw response.
49 */
50 GNUNET_CURL_RawParser parser;
51
52 /**
53 * Deallocate the response object.
54 */
55 GNUNET_CURL_ResponseCleaner cleaner;
42}; 56};
43 57
44 58
45/** 59/**
60 * Initialize reschedule context; with custom response parser
61 *
62 * @param ctx context to manage
63 * @return closure for #GNUNET_CURL_gnunet_scheduler_reschedule().
64 */
65struct GNUNET_CURL_RescheduleContext *
66GNUNET_CURL_gnunet_rc_create_with_parser (struct GNUNET_CURL_Context *ctx,
67 GNUNET_CURL_RawParser rp,
68 GNUNET_CURL_ResponseCleaner rc)
69{
70 struct GNUNET_CURL_RescheduleContext *rctx;
71
72 rctx = GNUNET_new (struct GNUNET_CURL_RescheduleContext);
73 rctx->ctx = ctx;
74 rctx->parser = rp;
75 rctx->cleaner = rc;
76
77 return rctx;
78}
79
80/**
46 * Initialize reschedule context. 81 * Initialize reschedule context.
47 * 82 *
48 * @param ctx context to manage 83 * @param ctx context to manage
@@ -55,6 +90,8 @@ GNUNET_CURL_gnunet_rc_create (struct GNUNET_CURL_Context *ctx)
55 90
56 rc = GNUNET_new (struct GNUNET_CURL_RescheduleContext); 91 rc = GNUNET_new (struct GNUNET_CURL_RescheduleContext);
57 rc->ctx = ctx; 92 rc->ctx = ctx;
93 rc->parser = (GNUNET_CURL_RawParser) &download_get_result;
94 rc->cleaner = (GNUNET_CURL_ResponseCleaner) &json_decref;
58 return rc; 95 return rc;
59} 96}
60 97
@@ -92,7 +129,10 @@ context_task (void *cls)
92 struct GNUNET_TIME_Relative delay; 129 struct GNUNET_TIME_Relative delay;
93 130
94 rc->task = NULL; 131 rc->task = NULL;
95 GNUNET_CURL_perform (rc->ctx); 132
133 GNUNET_CURL_perform2 (rc->ctx,
134 rc->parser,
135 rc->cleaner);
96 max_fd = -1; 136 max_fd = -1;
97 timeout = -1; 137 timeout = -1;
98 FD_ZERO (&read_fd_set); 138 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;
203typedef void 203typedef void
204(*GNUNET_CURL_JobCompletionCallback)(void *cls, 204(*GNUNET_CURL_JobCompletionCallback)(void *cls,
205 long response_code, 205 long response_code,
206 const json_t *json); 206 const void *response);
207 207
208 208
209/** 209/**
@@ -259,6 +259,18 @@ struct GNUNET_CURL_RescheduleContext *
259GNUNET_CURL_gnunet_rc_create (struct GNUNET_CURL_Context *ctx); 259GNUNET_CURL_gnunet_rc_create (struct GNUNET_CURL_Context *ctx);
260 260
261/** 261/**
262 * Initialize reschedule context; with custom response parser
263 *
264 * @param ctx context to manage
265 * @return closure for #GNUNET_CURL_gnunet_scheduler_reschedule().
266 */
267struct GNUNET_CURL_RescheduleContext *
268GNUNET_CURL_gnunet_rc_create_with_parser (struct GNUNET_CURL_Context *ctx,
269 GNUNET_CURL_RawParser rp,
270 GNUNET_CURL_ResponseCleaner rc);
271
272
273/**
262 * Destroy reschedule context. 274 * Destroy reschedule context.
263 * 275 *
264 * @param rc context to destroy 276 * @param rc context to destroy