rauc / rauc-hawkbit-updater

The RAUC hawkBit updater is a simple commandline tool/daemon that runs on your target and interfaces between RAUC and hawkBit's DDI API.
https://rauc-hawkbit-updater.readthedocs.io
GNU Lesser General Public License v2.1
58 stars 36 forks source link

Share connection between curl requests #170

Open rvdgracht opened 9 months ago

rvdgracht commented 9 months ago

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.

rvdgracht commented 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.

Bastian-Krause commented 8 months ago

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:

https://github.com/rauc/rauc-hawkbit-updater/blob/76f5a1dad2f42dc778d798bc0e68fcfbce690b65/.github/workflows/tests.yml#L16

rvdgracht commented 6 months ago

Maybe we should add -fsanitize=thread here

Added.