azure-sdk-for-cpp icon indicating copy to clipboard operation
azure-sdk-for-cpp copied to clipboard

Fix CPU spinning when curl_easy_send returns 0 bytes on SSL socket writes

Open harshitkr12 opened this issue 1 month ago • 7 comments

Summary:

Why ? When uploading blobs to Azure Storage over HTTPS (SSL/TLS), curl_easy_send() can return CURLE_OK with 0 bytes sent. This would lead to a retry without delay immediately, causing a tight CPU-spinning loop.

What ? Added a 10ms sleep when curl_easy_send() returns CURLE_OK with 0 bytes sent to prevent rapid retries and allow the OS scheduler to run other threads.

Test Plan:

cmake --build .
ctest -R "azure-core" --output-on-failure
>> 100% tests passed, 0 tests failed out of 459

Fixes #6817

harshitkr12 avatar Dec 15 '25 14:12 harshitkr12

Thank you for your contribution @harshitkr12! We will review the pull request and get back to you soon.

github-actions[bot] avatar Dec 15 '25 14:12 github-actions[bot]

Thank you! I am approving the pull request, it looks good to me. I'd like @LarryOsterman to review before merging.

@LarryOsterman, if you will be doing the next release (it is probably January 8, unless @ronniegeraghty says it is a week after), please make sure that the changelog has an entry for this fix, as well as the acknowledgements section + credit after the fix line, similar to the other fixes that we've taken. The upcoming release should probably be the beta.

OR, I think we can wait for the week of Jan 12th - it is still going to be a release week, and then I can make the release myself. I suggest we do that.

But just in case, here is the hange that we'll need for the CHANGELOG.md in core:

# Release History

## 1.17.0-beta.1 (2026-01-08)

### Bugs Fixed

- [[#6817]] Fix CPU spinning when curl_easy_send returns 0 bytes on SSL socket writes. (A community contribution, courtesy of _[[harshitkr12](https://github.com/harshitkr12)](https://github.com/harshitkr12)_)

### Acknowledgments

Thank you to our developer community members who helped to make Azure Core better with their contributions to this release:

- harshitkr12 _([GitHub](https://github.com/harshitkr12))_

I am going to follow up with Rubrik in the issue letting them know how they can start consuming it right away, if they need it.

antkmsft avatar Dec 19 '25 23:12 antkmsft

/azp run cpp - core

antkmsft avatar Dec 19 '25 23:12 antkmsft

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Dec 19 '25 23:12 azure-pipelines[bot]

Live tests are green.

antkmsft avatar Dec 19 '25 23:12 antkmsft

/azp run cpp - storage

antkmsft avatar Dec 20 '25 00:12 antkmsft

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Dec 20 '25 00:12 azure-pipelines[bot]

Thank you! I am approving the pull request, it looks good to me. I'd like @LarryOsterman to review before merging.

@LarryOsterman, if you will be doing the next release (it is probably January 8, unless @ronniegeraghty says it is a week after), please make sure that the changelog has an entry for this fix, as well as the acknowledgements section + credit after the fix line, similar to the other fixes that we've taken. The upcoming release should probably be the beta.

OR, I think we can wait for the week of Jan 12th - it is still going to be a release week, and then I can make the release myself. I suggest we do that.

But just in case, here is the hange that we'll need for the CHANGELOG.md in core:

# Release History

## 1.17.0-beta.1 (2026-01-08)

### Bugs Fixed

- [[#6817]] Fix CPU spinning when curl_easy_send returns 0 bytes on SSL socket writes. (A community contribution, courtesy of _[sushshring](https://github.com/harshitkr12)_)

### Acknowledgments

Thank you to our developer community members who helped to make Azure Core better with their contributions to this release:

- harshitkr12 _([GitHub](https://github.com/harshitkr12))_

I am going to follow up with Rubrik in the issue letting them know how they can start consuming it right away, if they need it.

January Release week is next week, the week of Jan 12th.

ronniegeraghty avatar Jan 07 '26 18:01 ronniegeraghty

@antkmsft @RickWinter Are we good to merge this PR? @agabhin has explained why we are using sleep_for instead of yield here - https://github.com/Azure/azure-sdk-for-cpp/pull/6890#discussion_r2650347894.

harshitkr12 avatar Jan 08 '26 14:01 harshitkr12