#3423 Fix rpm_hdr_size file closing
Merged by tkopecek. Opened by puiterwijk.
puiterwijk/koji fix_rpm_hdr_size_fileclose  into  master

Download 3423.patch

The current code will try to close a passed in file object, and will not
try to close a file object it opened when a string is passed in.
This results in either a leaked file object, or a file object that was
passed in to be closed after the function is called.

Signed-off-by: Patrick Uiterwijk patrick@puiterwijk.org

rebased onto 83d27abe7b2c45eca14540508140b6c9eeae9616

rebased onto 8fc27c848297f9d3f29e219cea1ac7a9f426971a

Fun fact: this bug has been in here since the initial code drop.

:thumbsup: (issue #3424)

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-ready

afaict, we never call this function with a file object, only with a filename. (Which must be the case since it would definitely error in the file object case)

In the string case, the created file object becomes unreferenced quickly, so likely closed by gc but not guaranteed to be timely, which I guess is why we've never run across leaking behavior from this (also, none of the processes that call this are normally long-lived).

anyway, thanks for the fix!

:thumbsup:

I hit this a few months ago already when doing head-signing for RHEL, but I forgot to file this (I am using Koji's functions to get headers etc), and at the time I just worked around it by passing paths into Koji.
I now again hit it when doing the head-signing work for Fedora, and now I decided to just fix it, since my current code tries to write as little as possible to disk.

So basically, this is indeed not an issue within the Koji client/server usecases.
And yeah GC does close the file descriptors, it just logs a warning.

Metadata Update from @tkopecek:
- Pull-request untagged with: testing-ready
- Pull-request tagged with: no_qe

pretty please pagure-ci rebuild

Commit e5e59c18 fixes this pull-request

Pull-Request has been merged by tkopecek

Metadata