Open rvdgracht opened 9 months ago
I have some concerns about sharing the connection (CURL_LOCK_DATA_CONNECT) between the mainloop (poller) and the download thread. The documentation states: "It is not supported to share connections between multiple concurrent threads." I did place locking on the shared data including CURL_LOCK_DATA_CONNECT though. I have succesfully tested this. So the mainloop can poll for status while the download thread is streaming data over the same connection. Maybe someone with more extensive libcurl knowledge can verify this.
I think inter-thread connection sharing as it's implemented here should be okay. Maybe we should add -fsanitize=thread
here, so we stumble upon any issues:
Maybe we should add
-fsanitize=thread
here
Added.
Using a curl_share between curl requests allows sharing an open connection and re-use cached DNS, PSL and TLS session id.
This change allows performing multiple requests without having to do re-perform the (full) TLS handshake.
For reference, on a stm32mp151c with OPTEE + pkcs11 TA a full TLS handshake takes ~8 seconds. Mostly due to small pager pool (internal sram) available for OPTEE.
With this change a mTLS curl request take around 60ms after the initial connection has been established.