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

DownloadCallbacks: Ensure end for every successful add_new_download #1814

Merged

Conversation

jrohel
Copy link
Contributor

@jrohel jrohel commented Oct 31, 2024

For every successful (ended without exception) call of add_new_download callback, the end callback is called once.

The code relied on librepo to call the end callback just once for each lr_target. Which works under normal conditions. But if there is an interruption in the librepo download (error, signal received) librepo will not call end callbacks for targets that have not yet started downloading. However, the add_new_download callback has already been called for them. For example, if a higher layer allocated resources on add_new_download and deallocated on end, resources would be lost.

The new code tracks this and calls the appropriate end callbacks. Also, an assert has been added to monitor for any attempt to double call the end callback.

@kontura kontura self-assigned this Nov 4, 2024
@kontura
Copy link
Contributor

kontura commented Nov 5, 2024

Since the updated unit tests pass even without the file/package_downloader changes can I ask when is the problem happening?

For every successful (ended without exception) call of
`add_new_download` callback, the `end` callback is called once.

The code relied on librepo to call the `end` callback just once for each
`lr_target`. Which works under normal conditions. But if there is
an interruption in the librepo download (error, signal received) librepo
will not call `end` callbacks for targets that have not yet started downloading.
However, the `add_new_download` callback has already been called for them.
For example, if a higher layer allocated resources on `add_new_download` and
deallocated on `end`, resources would be lost.

The new code tracks this and calls the appropriate `end` callbacks.
Also, an assert has been added to monitor for any attempt to double call
the `end` callback.
@jrohel jrohel force-pushed the DownloadCallbacks_ensure_end branch from aa5f68e to c1b2c63 Compare November 5, 2024 10:52
@jrohel
Copy link
Contributor Author

jrohel commented Nov 5, 2024

Since the updated unit tests pass even without the file/package_downloader changes can I ask when is the problem happening?

I have added a description of the resolved problem to the commit and PR.
The added unit tests pass with the original code, because under normal conditions librepo will call the end callback. The problem is when the librepo download is interrupted (error, signal).

Copy link
Contributor

@kontura kontura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thank you!

@kontura kontura added this pull request to the merge queue Nov 5, 2024
Merged via the queue into rpm-software-management:main with commit 1e6c03e Nov 5, 2024
20 checks passed
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.

2 participants