-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Description
curl 7.65.3 with woflSSL v4.1.0, cares 1_15_0, test base on this code example: https://curl.haxx.se/libcurl/c/multi-uv.html
test from os: macOS, linux, android. all has same issue.
CURLINFO_PRIMARY_IP, CURLINFO_PRIMARY_PORT return null and 0 at CURLMSG_DONE callback function. (test before curl_multi_assign(null), curl_multi_remove_handle )
CURL_POLL_REMOVE is called before CURLMSG_DONE, I guess this could be the problem.
I use getpeername to get the socket peer IP, on step CURL_POLL_REMOVE I can get the correct peer IP.
On step CURL_POLL_IN, if socketp is null, peer IP also is null. (Even I remove uv_close from CURL_POLL_REMOVE , so socket get reused without call uv_close)
I also try delay curl_multi_remove_handle until before curl_easy_cleanup get called, this will allow CURLINFO_ACTIVESOCKET return a valid socket fd (without delay curl_multi_remove_handle, CURLINFO_ACTIVESOCKET return -1 when easy finished ).
According to https://ec.haxx.se/libcurl-connectionreuse.html:
When you are using the multi API, the connection pool is instead kept associated with the multi handle. This allows you to cleanup and re-create easy handles freely without risking losing the connection pool, and it allows the connection used by one easy handle to get reused by a separate one in a later transfer.
In the test code, connection not reused all the time.
The TLS session cache also get destroyed when multi handle perform a new host request.
For TLS version < 1.3, If the socket peer IP remain same, and domain remain same, TLS session cache still not work. I guess because TLSv1.2 no 0-rtt handshake, and connection is not reused(the TLSv1.2 session cache should speed up the connection time cost, but the test code show the same time cost ).