cURL / Mailing Lists / curl-library / Single Mail

curl-library

Endless loop on curl_multi_cleanup

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Sun, 2 Oct 2016 22:06:44 +0200

I've discovered a case where curl_multi_cleanup() can end up in an endless
loop when it's called with a transfer ongoing. In such a case,
close_all_connections() loops around all the connections in the connection
cache calling Curl_disconnect() on each and not exiting until all connections
in the cache are closed. However, if the connection is still in use,
Curl_disconnect() does NOT remove the connection from the cache (the
Curl_disconnect, usecounter: code path) and the loop around the connection
cache continues, ad infinitum.

I'm not sure the right way to solve this. Should the forced-close bit be set on
all connections first to make sure they're closed? Or does whole situation
simply invalid because there aren't supposed to be any easy handles attached to
the multi handle as curl_multi_cleanup() is called? The man page doesn't
actually come right out and say that this isn't allowed, but does imply it.

This situation can occur in test 1500 when the TEST_ERR_MAJOR_BAD code path is
taken (such as during the memory torture test). That test doesn't actually
ever call curl_multi_remove_handle() as the man page recommends, and calls the
multi and easy cleanup functions in the opposite order to the recommendation,
which makes me think that other code out there doing the same and
curl_multi_cleanup() should handle the situation without hanging.

>>> Dan
-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2016-10-02