tighten formatting rules
[oweals/gnunet.git] / src / curl / curl.c
1 /*
2    This file is part of GNUnet
3    Copyright (C) 2014, 2015, 2016, 2018 GNUnet e.V.
4
5    GNUnet is free software: you can redistribute it and/or modify it
6    under the terms of the GNU Affero General Public License as published
7    by the Free Software Foundation, either version 3 of the License,
8    or (at your option) any later version.
9
10    GNUnet is distributed in the hope that it will be useful, but
11    WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Affero General Public License for more details.
14
15    You should have received a copy of the GNU Affero General Public License
16    along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18      SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 /**
21  * @file curl/curl.c
22  * @brief API for downloading JSON via CURL
23  * @author Sree Harsha Totakura <sreeharsha@totakura.in>
24  * @author Christian Grothoff
25  */
26 #include "platform.h"
27 #include <jansson.h>
28 #include "gnunet_curl_lib.h"
29
30 #if ENABLE_BENCHMARK
31 #include "../util/benchmark.h"
32 #endif
33
34
35 /**
36  * Log error related to CURL operations.
37  *
38  * @param type log level
39  * @param function which function failed to run
40  * @param code what was the curl error code
41  */
42 #define CURL_STRERROR(type, function, code)                                \
43   GNUNET_log (type,                                                        \
44               "Curl function `%s' has failed at `%s:%d' with error: %s\n", \
45               function,                                                    \
46               __FILE__,                                                    \
47               __LINE__,                                                    \
48               curl_easy_strerror (code));
49
50 /**
51  * Print JSON parsing related error information
52  */
53 #define JSON_WARN(error)                                 \
54   GNUNET_log (GNUNET_ERROR_TYPE_WARNING,                 \
55               "JSON parsing failed at %s:%u: %s (%s)\n", \
56               __FILE__,                                  \
57               __LINE__,                                  \
58               error.text,                                \
59               error.source)
60
61
62 /**
63  * Failsafe flag. Raised if our constructor fails to initialize
64  * the Curl library.
65  */
66 static int curl_fail;
67
68 /**
69  * Jobs are CURL requests running within a `struct GNUNET_CURL_Context`.
70  */
71 struct GNUNET_CURL_Job
72 {
73   /**
74    * We keep jobs in a DLL.
75    */
76   struct GNUNET_CURL_Job *next;
77
78   /**
79    * We keep jobs in a DLL.
80    */
81   struct GNUNET_CURL_Job *prev;
82
83   /**
84    * Easy handle of the job.
85    */
86   CURL *easy_handle;
87
88   /**
89    * Context this job runs in.
90    */
91   struct GNUNET_CURL_Context *ctx;
92
93   /**
94    * Function to call upon completion.
95    */
96   GNUNET_CURL_JobCompletionCallback jcc;
97
98   /**
99    * Closure for @e jcc.
100    */
101   void *jcc_cls;
102
103   /**
104    * Buffer for response received from CURL.
105    */
106   struct GNUNET_CURL_DownloadBuffer db;
107
108   /**
109    * Headers used for this job, the list needs to be freed
110    * after the job has finished.
111    */
112   struct curl_slist *job_headers;
113 };
114
115
116 /**
117  * Context
118  */
119 struct GNUNET_CURL_Context
120 {
121   /**
122    * Curl multi handle
123    */
124   CURLM *multi;
125
126   /**
127    * Curl share handle
128    */
129   CURLSH *share;
130
131   /**
132    * We keep jobs in a DLL.
133    */
134   struct GNUNET_CURL_Job *jobs_head;
135
136   /**
137    * We keep jobs in a DLL.
138    */
139   struct GNUNET_CURL_Job *jobs_tail;
140
141   /**
142    * Headers common for all requests in the context.
143    */
144   struct curl_slist *common_headers;
145
146   /**
147    * If non-NULL, the async scope ID is sent in a request
148    * header of this name.
149    */
150   const char *async_scope_id_header;
151
152   /**
153    * Function we need to call whenever the event loop's
154    * socket set changed.
155    */
156   GNUNET_CURL_RescheduleCallback cb;
157
158   /**
159    * Closure for @e cb.
160    */
161   void *cb_cls;
162 };
163
164
165 /**
166  * Initialise this library.  This function should be called before using any of
167  * the following functions.
168  *
169  * @param cb function to call when rescheduling is required
170  * @param cb_cls closure for @a cb
171  * @return library context
172  */
173 struct GNUNET_CURL_Context *
174 GNUNET_CURL_init (GNUNET_CURL_RescheduleCallback cb, void *cb_cls)
175 {
176   struct GNUNET_CURL_Context *ctx;
177   CURLM *multi;
178   CURLSH *share;
179
180   if (curl_fail)
181   {
182     GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Curl was not initialised properly\n");
183     return NULL;
184   }
185   if (NULL == (multi = curl_multi_init ()))
186   {
187     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
188                 "Failed to create a Curl multi handle\n");
189     return NULL;
190   }
191   if (NULL == (share = curl_share_init ()))
192   {
193     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
194                 "Failed to create a Curl share handle\n");
195     return NULL;
196   }
197   ctx = GNUNET_new (struct GNUNET_CURL_Context);
198   ctx->cb = cb;
199   ctx->cb_cls = cb_cls;
200   ctx->multi = multi;
201   ctx->share = share;
202   return ctx;
203 }
204
205
206 /**
207  * Enable sending the async scope ID as a header.
208  *
209  * @param ctx the context to enable this for
210  * @param header_name name of the header to send.
211  */
212 void
213 GNUNET_CURL_enable_async_scope_header (struct GNUNET_CURL_Context *ctx,
214                                        const char *header_name)
215 {
216   ctx->async_scope_id_header = header_name;
217 }
218
219
220 /**
221  * Callback used when downloading the reply to an HTTP request.
222  * Just appends all of the data to the `buf` in the
223  * `struct DownloadBuffer` for further processing. The size of
224  * the download is limited to #GNUNET_MAX_MALLOC_CHECKED, if
225  * the download exceeds this size, we abort with an error.
226  *
227  * @param bufptr data downloaded via HTTP
228  * @param size size of an item in @a bufptr
229  * @param nitems number of items in @a bufptr
230  * @param cls the `struct DownloadBuffer`
231  * @return number of bytes processed from @a bufptr
232  */
233 static size_t
234 download_cb (char *bufptr, size_t size, size_t nitems, void *cls)
235 {
236   struct GNUNET_CURL_DownloadBuffer *db = cls;
237   size_t msize;
238   void *buf;
239
240   if (0 == size * nitems)
241   {
242     /* Nothing (left) to do */
243     return 0;
244   }
245   msize = size * nitems;
246   if ((msize + db->buf_size) >= GNUNET_MAX_MALLOC_CHECKED)
247   {
248     db->eno = ENOMEM;
249     return 0;   /* signals an error to curl */
250   }
251   db->buf = GNUNET_realloc (db->buf, db->buf_size + msize);
252   buf = db->buf + db->buf_size;
253   GNUNET_memcpy (buf, bufptr, msize);
254   db->buf_size += msize;
255   return msize;
256 }
257
258
259 /**
260  * Schedule a CURL request to be executed and call the given @a jcc
261  * upon its completion.  Note that the context will make use of the
262  * CURLOPT_PRIVATE facility of the CURL @a eh.
263  *
264  * This function modifies the CURL handle to add the
265  * "Content-Type: application/json" header if @a add_json is set.
266  *
267  * @param ctx context to execute the job in
268  * @param eh curl easy handle for the request, will be executed AND
269  *           cleaned up.  NOTE: the handle should _never_ have gotten
270  *           any headers list, as that would then be ovverridden by
271  *           @a jcc.  Therefore, always pass custom headers as the
272  *           @a job_headers parameter.
273  * @param job_headers extra headers to add for this request
274  * @param jcc callback to invoke upon completion
275  * @param jcc_cls closure for @a jcc
276  * @return NULL on error (in this case, @eh is still released!)
277  */
278 struct GNUNET_CURL_Job *
279 GNUNET_CURL_job_add2 (struct GNUNET_CURL_Context *ctx,
280                       CURL *eh,
281                       const struct curl_slist *job_headers,
282                       GNUNET_CURL_JobCompletionCallback jcc,
283                       void *jcc_cls)
284 {
285   struct GNUNET_CURL_Job *job;
286   struct curl_slist *all_headers = NULL;
287
288   for (const struct curl_slist *curr = job_headers; curr != NULL;
289        curr = curr->next)
290   {
291     GNUNET_assert (NULL !=
292                    (all_headers = curl_slist_append (all_headers, curr->data)));
293   }
294
295   for (const struct curl_slist *curr = ctx->common_headers; curr != NULL;
296        curr = curr->next)
297   {
298     GNUNET_assert (NULL !=
299                    (all_headers = curl_slist_append (all_headers, curr->data)));
300   }
301
302   if (NULL != ctx->async_scope_id_header)
303   {
304     struct GNUNET_AsyncScopeSave scope;
305
306     GNUNET_async_scope_get (&scope);
307     if (GNUNET_YES == scope.have_scope)
308     {
309       char *aid_header = NULL;
310       aid_header =
311         GNUNET_STRINGS_data_to_string_alloc (&scope.scope_id,
312                                              sizeof(
313                                                struct GNUNET_AsyncScopeId));
314       GNUNET_assert (NULL != aid_header);
315       GNUNET_assert (NULL != curl_slist_append (all_headers, aid_header));
316       GNUNET_free (aid_header);
317     }
318   }
319
320   if (CURLE_OK != curl_easy_setopt (eh, CURLOPT_HTTPHEADER, all_headers))
321   {
322     GNUNET_break (0);
323     curl_slist_free_all (all_headers);
324     curl_easy_cleanup (eh);
325     return NULL;
326   }
327
328   job = GNUNET_new (struct GNUNET_CURL_Job);
329   job->job_headers = all_headers;
330
331   if ((CURLE_OK != curl_easy_setopt (eh, CURLOPT_PRIVATE, job)) ||
332       (CURLE_OK !=
333        curl_easy_setopt (eh, CURLOPT_WRITEFUNCTION, &download_cb)) ||
334       (CURLE_OK != curl_easy_setopt (eh, CURLOPT_WRITEDATA, &job->db)) ||
335       (CURLE_OK != curl_easy_setopt (eh, CURLOPT_SHARE, ctx->share)) ||
336       (CURLM_OK != curl_multi_add_handle (ctx->multi, eh)))
337   {
338     GNUNET_break (0);
339     GNUNET_free (job);
340     curl_easy_cleanup (eh);
341     return NULL;
342   }
343
344   job->easy_handle = eh;
345   job->ctx = ctx;
346   job->jcc = jcc;
347   job->jcc_cls = jcc_cls;
348   GNUNET_CONTAINER_DLL_insert (ctx->jobs_head, ctx->jobs_tail, job);
349   ctx->cb (ctx->cb_cls);
350   return job;
351 }
352
353
354 /**
355  * Schedule a CURL request to be executed and call the given @a jcc
356  * upon its completion.  Note that the context will make use of the
357  * CURLOPT_PRIVATE facility of the CURL @a eh.
358  *
359  * This function modifies the CURL handle to add the
360  * "Content-Type: application/json" header if @a add_json is set.
361  *
362  * @param ctx context to execute the job in
363  * @param eh curl easy handle for the request, will
364  *           be executed AND cleaned up
365  * @param add_json add "application/json" content type header
366  * @param jcc callback to invoke upon completion
367  * @param jcc_cls closure for @a jcc
368  * @return NULL on error (in this case, @eh is still released!)
369  */
370 struct GNUNET_CURL_Job *
371 GNUNET_CURL_job_add (struct GNUNET_CURL_Context *ctx,
372                      CURL *eh,
373                      int add_json,
374                      GNUNET_CURL_JobCompletionCallback jcc,
375                      void *jcc_cls)
376 {
377   struct GNUNET_CURL_Job *job;
378   struct curl_slist *job_headers = NULL;
379
380   if (GNUNET_YES == add_json)
381   {
382     GNUNET_assert (
383       NULL != (job_headers =
384                  curl_slist_append (NULL, "Content-Type: application/json")));
385   }
386
387   job = GNUNET_CURL_job_add2 (ctx, eh, job_headers, jcc, jcc_cls);
388   curl_slist_free_all (job_headers);
389   return job;
390 }
391
392
393 /**
394  * Cancel a job.  Must only be called before the job completion
395  * callback is called for the respective job.
396  *
397  * @param job job to cancel
398  */
399 void
400 GNUNET_CURL_job_cancel (struct GNUNET_CURL_Job *job)
401 {
402   struct GNUNET_CURL_Context *ctx = job->ctx;
403
404   GNUNET_CONTAINER_DLL_remove (ctx->jobs_head, ctx->jobs_tail, job);
405   GNUNET_break (CURLM_OK ==
406                 curl_multi_remove_handle (ctx->multi, job->easy_handle));
407   curl_easy_cleanup (job->easy_handle);
408   GNUNET_free_non_null (job->db.buf);
409   curl_slist_free_all (job->job_headers);
410   GNUNET_free (job);
411 }
412
413
414 /**
415  * Obtain information about the final result about the
416  * HTTP download. If the download was successful, parses
417  * the JSON in the @a db and returns it. Also returns
418  * the HTTP @a response_code.  If the download failed,
419  * the return value is NULL.  The response code is set
420  * in any case, on download errors to zero.
421  *
422  * Calling this function also cleans up @a db.
423  *
424  * @param db download buffer
425  * @param eh CURL handle (to get the response code)
426  * @param[out] response_code set to the HTTP response code
427  *             (or zero if we aborted the download, i.e.
428  *              because the response was too big, or if
429  *              the JSON we received was malformed).
430  * @return NULL if downloading a JSON reply failed.
431  */
432 void *
433 GNUNET_CURL_download_get_result_ (struct GNUNET_CURL_DownloadBuffer *db,
434                                   CURL *eh,
435                                   long *response_code)
436 {
437   json_t *json;
438   json_error_t error;
439   char *ct;
440
441   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
442               "Downloaded body: %.*s\n",
443               (int) db->buf_size,
444               (char *) db->buf);
445
446   if ((CURLE_OK != curl_easy_getinfo (eh, CURLINFO_CONTENT_TYPE, &ct)) ||
447       (NULL == ct) || (0 != strcasecmp (ct, "application/json")))
448   {
449     /* No content type or explicitly not JSON, refuse to parse
450        (but keep response code) */
451     if (CURLE_OK !=
452         curl_easy_getinfo (eh, CURLINFO_RESPONSE_CODE, response_code))
453     {
454       /* unexpected error... */
455       GNUNET_break (0);
456       *response_code = 0;
457     }
458     if (0 != db->buf_size)
459       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
460                   "Did NOT detect response as JSON\n");
461     return NULL;
462   }
463   json = NULL;
464   if (0 == db->eno)
465   {
466     json = json_loadb (db->buf,
467                        db->buf_size,
468                        JSON_REJECT_DUPLICATES | JSON_DISABLE_EOF_CHECK,
469                        &error);
470     if (NULL == json)
471     {
472       JSON_WARN (error);
473       *response_code = 0;
474     }
475   }
476   GNUNET_free_non_null (db->buf);
477   db->buf = NULL;
478   db->buf_size = 0;
479   if (NULL != json)
480   {
481     if (CURLE_OK !=
482         curl_easy_getinfo (eh, CURLINFO_RESPONSE_CODE, response_code))
483     {
484       /* unexpected error... */
485       GNUNET_break (0);
486       *response_code = 0;
487     }
488   }
489   return json;
490 }
491
492
493 /**
494  * Add custom request header.
495  *
496  * @param ctx cURL context.
497  * @param header header string; will be given to the context AS IS.
498  * @return #GNUNET_OK if no errors occurred, #GNUNET_SYSERR otherwise.
499  */
500 int
501 GNUNET_CURL_append_header (struct GNUNET_CURL_Context *ctx, const char *header)
502 {
503   ctx->common_headers = curl_slist_append (ctx->common_headers, header);
504   if (NULL == ctx->common_headers)
505     return GNUNET_SYSERR;
506
507   return GNUNET_OK;
508 }
509
510
511 /**
512  * Run the main event loop for the Taler interaction.
513  *
514  * @param ctx the library context
515  * @param rp parses the raw response returned from
516  *        the Web server.
517  * @param rc cleans/frees the response
518  */
519 void
520 GNUNET_CURL_perform2 (struct GNUNET_CURL_Context *ctx,
521                       GNUNET_CURL_RawParser rp,
522                       GNUNET_CURL_ResponseCleaner rc)
523 {
524   CURLMsg *cmsg;
525   int n_running;
526   int n_completed;
527
528   (void) curl_multi_perform (ctx->multi, &n_running);
529   while (NULL != (cmsg = curl_multi_info_read (ctx->multi, &n_completed)))
530   {
531     struct GNUNET_CURL_Job *job;
532     long response_code;
533     void *response;
534
535     /* Only documented return value is CURLMSG_DONE */
536     GNUNET_break (CURLMSG_DONE == cmsg->msg);
537     GNUNET_assert (CURLE_OK == curl_easy_getinfo (cmsg->easy_handle,
538                                                   CURLINFO_PRIVATE,
539                                                   (char **) &job));
540     GNUNET_assert (job->ctx == ctx);
541     response_code = 0;
542     response = rp (&job->db, job->easy_handle, &response_code);
543 #if ENABLE_BENCHMARK
544     {
545       char *url = NULL;
546       double total_as_double = 0;
547       struct GNUNET_TIME_Relative total;
548       struct UrlRequestData *urd;
549       /* Some care required, as curl is using data types (long vs curl_off_t vs
550        * double) inconsistently to store byte count. */
551       curl_off_t size_curl = 0;
552       long size_long = 0;
553       uint64_t bytes_sent = 0;
554       uint64_t bytes_received = 0;
555
556       GNUNET_break (CURLE_OK == curl_easy_getinfo (cmsg->easy_handle,
557                                                    CURLINFO_TOTAL_TIME,
558                                                    &total_as_double));
559       total.rel_value_us = total_as_double * 1000 * 1000;
560
561       GNUNET_break (CURLE_OK == curl_easy_getinfo (cmsg->easy_handle,
562                                                    CURLINFO_EFFECTIVE_URL,
563                                                    &url));
564
565       /* HEADER_SIZE + SIZE_DOWNLOAD_T is hopefully the total
566          number of bytes received, not clear from curl docs. */
567
568       GNUNET_break (CURLE_OK == curl_easy_getinfo (cmsg->easy_handle,
569                                                    CURLINFO_HEADER_SIZE,
570                                                    &size_long));
571       bytes_received += size_long;
572
573       GNUNET_break (CURLE_OK == curl_easy_getinfo (cmsg->easy_handle,
574                                                    CURLINFO_SIZE_DOWNLOAD_T,
575                                                    &size_curl));
576       bytes_received += size_curl;
577
578       /* REQUEST_SIZE + SIZE_UPLOAD_T is hopefully the total number of bytes
579          sent, again docs are not completely clear. */
580
581       GNUNET_break (CURLE_OK == curl_easy_getinfo (cmsg->easy_handle,
582                                                    CURLINFO_REQUEST_SIZE,
583                                                    &size_long));
584       bytes_sent += size_long;
585
586       /* We obtain this value to check an invariant, but never use it otherwise. */
587       GNUNET_break (CURLE_OK == curl_easy_getinfo (cmsg->easy_handle,
588                                                    CURLINFO_SIZE_UPLOAD_T,
589                                                    &size_curl));
590
591       /* CURLINFO_SIZE_UPLOAD_T <= CURLINFO_REQUEST_SIZE should
592          be an invariant.
593          As verified with
594          curl -w "foo%{size_request} -XPOST --data "ABC" $URL
595          the CURLINFO_REQUEST_SIZE should be the whole size of the request
596          including headers and body.
597        */GNUNET_break (size_curl <= size_long);
598
599       urd = get_url_benchmark_data (url, (unsigned int) response_code);
600       urd->count++;
601       urd->time = GNUNET_TIME_relative_add (urd->time, total);
602       urd->time_max = GNUNET_TIME_relative_max (total, urd->time_max);
603       urd->bytes_sent += bytes_sent;
604       urd->bytes_received += bytes_received;
605     }
606 #endif
607     job->jcc (job->jcc_cls, response_code, response);
608     rc (response);
609     GNUNET_CURL_job_cancel (job);
610   }
611 }
612
613
614 /**
615  * Run the main event loop for the Taler interaction.
616  *
617  * @param ctx the library context
618  */
619 void
620 GNUNET_CURL_perform (struct GNUNET_CURL_Context *ctx)
621 {
622   GNUNET_CURL_perform2 (ctx,
623                         &GNUNET_CURL_download_get_result_,
624                         (GNUNET_CURL_ResponseCleaner) & json_decref);
625 }
626
627
628 /**
629  * Obtain the information for a select() call to wait until
630  * #GNUNET_CURL_perform() is ready again.  Note that calling
631  * any other GNUNET_CURL-API may also imply that the library
632  * is again ready for #GNUNET_CURL_perform().
633  *
634  * Basically, a client should use this API to prepare for select(),
635  * then block on select(), then call #GNUNET_CURL_perform() and then
636  * start again until the work with the context is done.
637  *
638  * This function will NOT zero out the sets and assumes that @a max_fd
639  * and @a timeout are already set to minimal applicable values.  It is
640  * safe to give this API FD-sets and @a max_fd and @a timeout that are
641  * already initialized to some other descriptors that need to go into
642  * the select() call.
643  *
644  * @param ctx context to get the event loop information for
645  * @param read_fd_set will be set for any pending read operations
646  * @param write_fd_set will be set for any pending write operations
647  * @param except_fd_set is here because curl_multi_fdset() has this argument
648  * @param max_fd set to the highest FD included in any set;
649  *        if the existing sets have no FDs in it, the initial
650  *        value should be "-1". (Note that `max_fd + 1` will need
651  *        to be passed to select().)
652  * @param timeout set to the timeout in milliseconds (!); -1 means
653  *        no timeout (NULL, blocking forever is OK), 0 means to
654  *        proceed immediately with #GNUNET_CURL_perform().
655  */
656 void
657 GNUNET_CURL_get_select_info (struct GNUNET_CURL_Context *ctx,
658                              fd_set *read_fd_set,
659                              fd_set *write_fd_set,
660                              fd_set *except_fd_set,
661                              int *max_fd,
662                              long *timeout)
663 {
664   long to;
665   int m;
666
667   m = -1;
668   GNUNET_assert (CURLM_OK == curl_multi_fdset (ctx->multi,
669                                                read_fd_set,
670                                                write_fd_set,
671                                                except_fd_set,
672                                                &m));
673   to = *timeout;
674   *max_fd = GNUNET_MAX (m, *max_fd);
675   GNUNET_assert (CURLM_OK == curl_multi_timeout (ctx->multi, &to));
676
677   /* Only if what we got back from curl is smaller than what we
678      already had (-1 == infinity!), then update timeout */
679   if ((to < *timeout) && (-1 != to))
680     *timeout = to;
681   if ((-1 == (*timeout)) && (NULL != ctx->jobs_head))
682     *timeout = to;
683 }
684
685
686 /**
687  * Cleanup library initialisation resources.  This function should be called
688  * after using this library to cleanup the resources occupied during library's
689  * initialisation.
690  *
691  * @param ctx the library context
692  */
693 void
694 GNUNET_CURL_fini (struct GNUNET_CURL_Context *ctx)
695 {
696   /* all jobs must have been cancelled at this time, assert this */
697   GNUNET_assert (NULL == ctx->jobs_head);
698   curl_share_cleanup (ctx->share);
699   curl_multi_cleanup (ctx->multi);
700   curl_slist_free_all (ctx->common_headers);
701   GNUNET_free (ctx);
702 }
703
704
705 /**
706  * Initial global setup logic, specifically runs the Curl setup.
707  */
708 __attribute__ ((constructor)) void
709 GNUNET_CURL_constructor__ (void)
710 {
711   CURLcode ret;
712
713   if (CURLE_OK != (ret = curl_global_init (CURL_GLOBAL_DEFAULT)))
714   {
715     CURL_STRERROR (GNUNET_ERROR_TYPE_ERROR, "curl_global_init", ret);
716     curl_fail = 1;
717   }
718 }
719
720
721 /**
722  * Cleans up after us, specifically runs the Curl cleanup.
723  */
724 __attribute__ ((destructor)) void
725 GNUNET_CURL_destructor__ (void)
726 {
727   if (curl_fail)
728     return;
729   curl_global_cleanup ();
730 }
731
732
733 /* end of curl.c */