curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder Daniel himself.

Re: Wrong connection reuse case for Share interface

From: Daniel Stenberg via curl-library <curl-library_at_lists.haxx.se>
Date: Thu, 2 Jul 2026 18:19:31 +0200 (CEST)

On Wed, 1 Jul 2026, Dmitry Karpov via curl-library wrote:

> * Run the transfer using multi interface to some point where it will be
> abandoned (i.e. application may make this decision due to lack of space
> where to write incoming data etc)

> * Set share to NULL on "abandoned" easy handle to avoid using the share on
> that transfer further and remove it from the multi handle (via
> curl_multi_remove_handle()).

Sharing was not designed to get dynamically modified during transfers. You
should remove the easy handle from the multi first, then change sharing
options.

The CURLOPT_SHARE man page has this wording since a couple of months back:

   Warning: adding a *share* and then setting it to NULL while the transfer is
   ongoing is discouraged and may lead to undefined behavior.

That said, we can of course add code to handle this specific case better.

-- 
  / daniel.haxx.se || https://rock-solid.curl.dev
-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html
Received on 2026-07-02