You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CONNECT_ONLY connections can get closed when cache is full #4369
There was a discussion recently about connection cache and CONNECT_ONLY connections. in this issue #3983 (comment)_ . And I think I've just hit the same thing.
I use CONNECT_ONLY to establish the connection and then put filedescriptor in own event loop to do some websocket communication. Recently I've noticed that sometimes connection is closed when it's returned to cache. I think this makes CURLINFO_ACTIVESOCKET unusable since Curl_conncache_return_conn does not consider CONNECT_ONLY connection as in use.
I don't see how this is a bug. This seems to work exactly as intended:
You limit libcurl to only keep one connection alive.
You issue a request that sets up a connect-only request , performs that and extracts the socket
You then create a new request, that cannot reuse the first connection and that runs.
When the second request completes, it puts it back in the connection cache, finds that it needs to "kill off" one to fit it within the set limit. It then closes the oldest.
I have just set the cache size to one to make this easier to reproduce. But I've experienced this even with default setting. It behaves exactly as you described. The problem is the CONNECT_ONLY connections with extracted socket using CURLINFO_ACTIVESOCKET probably should not be closed (until curl_easy_cleanup is called). As this makes extracted socket unusable.
Activity
bagder commentedon Dec 9, 2019
I don't see how this is a bug. This seems to work exactly as intended:
Where is the error here?
loblik commentedon Dec 10, 2019
I have just set the cache size to one to make this easier to reproduce. But I've experienced this even with default setting. It behaves exactly as you described. The problem is the CONNECT_ONLY connections with extracted socket using CURLINFO_ACTIVESOCKET probably should not be closed (until curl_easy_cleanup is called). As this makes extracted socket unusable.
bagder commentedon Dec 10, 2019
The error here is probably that the connection should be treated as in use and thus shouldn't be considered for closing.
conncache: CONNECT_ONLY connections are now assumed in-use always
loblik commentedon Dec 10, 2019
Yes. I cannot reproduce it with that change anymore. Thanks