curl_easy_setopt(xfer->handle, CURLOPT_ACCEPT_ENCODING, "");
// Reference back to this xfer
- curl_easy_setopt(xfer->handle, CURLOPT_PRIVATE, xfer);
+ curl_easy_setopt(xfer->handle, CURLOPT_PRIVATE, pakfire_xfer_ref(xfer));
// Follow any redirects
curl_easy_setopt(xfer->handle, CURLOPT_FOLLOWLOCATION, 1);
}
pakfire_xfer_error_code_t pakfire_xfer_done(struct pakfire_xfer* xfer, int code) {
+ struct pakfire_xfer* private = NULL;
CURL* h = xfer->handle;
int r;
const char* scheme = NULL;
curl_off_t upload_size = 0;
curl_off_t upload_speed = 0;
+ // Fetch the private pointer to this xfer
+ r = curl_easy_getinfo(h, CURLINFO_PRIVATE, &private);
+ if (r) {
+ CTX_ERROR(xfer->ctx,
+ "Could not fetch the private pointer: %s\n", curl_easy_strerror(r));
+ goto ERROR;
+ }
+
+ // Check if the private pointer was set
+ if (!private) {
+ CTX_ERROR(xfer->ctx, "Private pointer not set\n");
+ r = -EINVAL;
+ goto ERROR;
+ }
+
+ // Reset the private pointer
+ r = curl_easy_setopt(h, CURLOPT_PRIVATE, NULL);
+ if (r) {
+ CTX_ERROR(xfer->ctx,
+ "Could not reset the private pointer: %s\n", curl_easy_strerror(r));
+ goto ERROR;
+ }
+
// Finish progress
r = pakfire_progress_finish(xfer->progress);
if (r)
// Remove the handle
if (xfer->client)
pakfire_httpclient_remove_xfer(xfer->client, xfer);
+ if (private)
+ pakfire_xfer_unref(private);
return r;
}