Displaying 4 results from an estimated 4 matches for "curl_multi_cleanup".
2024 Apr 25
1
Big speedup in install.packages() by re-using connections
...libcurl.c (working copy)
@@ -55,6 +55,47 @@
static int current_timeout = 0;
+// The multi-handle is shared between downloads for reusing connections
+static CURLM *shared_mhnd = NULL;
+static SEXP mhnd_sentinel = NULL;
+
+static void cleanup_mhnd(SEXP ignored)
+{
+ if(shared_mhnd){
+ curl_multi_cleanup(shared_mhnd);
+ shared_mhnd = NULL;
+ }
+ curl_global_cleanup();
+}
+static void rollback_mhnd_sentinel(void* sentinel) {
+ // Failed to allocate memory while registering a finalizer,
+ // therefore must release the object
+ R_ReleaseObject((SEXP)sentinel);
+}
+static CURLM *g...
2024 Apr 25
1
Big speedup in install.packages() by re-using connections
I'd like to raise this again now that 4.4 is out.
Below is a more complete patch which includes a function to properly
cleanup libcurl when R quits. Implementing this is a little tricky
because libcurl is a separate "module" in R, perhaps there is a better
way, but this works:
view: https://github.com/r-devel/r-svn/pull/166/files
patch:
2024 Sep 02
1
Big speedup in install.packages() by re-using connections
...static int current_timeout = 0;
>
> +// The multi-handle is shared between downloads for reusing connections
> +static CURLM *shared_mhnd = NULL;
> +static SEXP mhnd_sentinel = NULL;
> +
> +static void cleanup_mhnd(SEXP ignored)
> +{
> + if(shared_mhnd){
> + curl_multi_cleanup(shared_mhnd);
> + shared_mhnd = NULL;
> + }
> + curl_global_cleanup();
> +}
> +static void rollback_mhnd_sentinel(void* sentinel) {
> + // Failed to allocate memory while registering a finalizer,
> + // therefore must release the object
> + R_ReleaseObj...
2018 Dec 04
3
patch to support custom HTTP headers in download.file() and url()
...(hnd[i], CURLOPT_HTTPHEADER, headers);
/* check that destfile can be written */
file = translateChar(STRING_ELT(sfile, i));
@@ -660,7 +678,7 @@ in_do_curlDownload(SEXP call, SEXP op, SEXP args, SEXP rho)
if(nurls == 1)
curl_easy_getinfo(hnd[0], CURLINFO_RESPONSE_CODE, &status);
curl_multi_cleanup(mhnd);
- if (!cacheOK) curl_slist_free_all(slist1);
+ curl_slist_free_all(headers);
if(nurls > 1) {
if (n_err == nurls) error(_("cannot download any files"));
@@ -703,6 +721,7 @@ typedef struct Curlconn {
Rboolean available; // to be read out
int sr; // 'sti...