diff options
author | Marcello Stanisci <stanisci.m@gmail.com> | 2018-10-17 20:02:35 +0200 |
---|---|---|
committer | Marcello Stanisci <stanisci.m@gmail.com> | 2018-10-17 20:02:35 +0200 |
commit | 418bf5953acdba2e325528d739fb115b51b7141f (patch) | |
tree | 7fea556ead0f84b870b382bec1577a76f15b9d00 /src/curl/curl_reschedule.c | |
parent | 25b9d3dfa6fb538627e6cd8ed4b5741e18b752d9 (diff) | |
download | gnunet-418bf5953acdba2e325528d739fb115b51b7141f.tar.gz gnunet-418bf5953acdba2e325528d739fb115b51b7141f.zip |
curl: reschedule uses GNUNET_CURL_perform2.
Diffstat (limited to 'src/curl/curl_reschedule.c')
-rw-r--r-- | src/curl/curl_reschedule.c | 42 |
1 files changed, 41 insertions, 1 deletions
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 | ||
27 | extern void * | ||
28 | download_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 | */ | ||
65 | struct GNUNET_CURL_RescheduleContext * | ||
66 | GNUNET_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); |