Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplified lr_perform()'s loop to prevent busy wait #144

Merged
merged 1 commit into from Mar 25, 2019
Merged

Simplified lr_perform()'s loop to prevent busy wait #144

merged 1 commit into from Mar 25, 2019

Conversation

ydroneaud
Copy link
Contributor

Calling curl_multi_perform() in a loop is actually
busy waiting for data being available on the socket.

The whole logic in lr_perform() can be simplified
allowing more efficient processing. The function has
to repeatedly do:

  1. call curl_multi_perform() for curl to fetch data if needed/available
  2. call check_transfer_statuses() to check download status
  3. if curl needs more data, wait for the socket to have some

Once there's no need for more data, and there's no other
transfer pending, lr_perform() can return TRUE.

The function can be further simplified by

This fixes https://bugzilla.redhat.com/show_bug.cgi?id=1691856

Fixes: 208edbe ('Reduce download delays by using still_running correctly.')

Calling curl_multi_perform() in a loop is actually
busy waiting for data being available on the socket.

The whole logic in lr_perform() can be simplified
allowing more efficient processing. The function has
to repeatedly do:

1) call curl_multi_perform() for curl to fetch data if needed/available
2) call check_transfer_statuses() to check download status
3) if curl needs more data, wait for the socket to have some

Once there's no need for more data, and there's no other
transfer pending, lr_perform() can return TRUE.

The function can be further simplified by
- assuming curl_multi_perform() is not returning CURLM_CALL_MULTI_PERFORM
  require cURL 7.20, https://curl.haxx.se/libcurl/c/curl_multi_perform.html
- using curl_multi_wait() instead of select()
  require cURL 7.28, https://curl.haxx.se/libcurl/c/curl_multi_wait.html

This fixes https://bugzilla.redhat.com/show_bug.cgi?id=1691856

Fixes: 208edbe ('Reduce download delays by using still_running correctly.')
@jrohel
Copy link
Contributor

jrohel commented Mar 25, 2019

Thank you. Fix with nice simplification.

@jrohel jrohel merged commit 5c4e631 into rpm-software-management:master Mar 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants