HomePhorge

(#14964) Unlink Tempfiles consistently across different ruby versions
4c18d085e0b9Unpublished

Unpublished Commit ยท Learn More

Repository Importing: This repository is still importing.

Description

(#14964) Unlink Tempfiles consistently across different ruby versions

The previous fix for #14964 relied on inconsisent behavior of ruby 1.8's
Tempfile#close! method, which is called by close(true). Although
the ruby documentation says close! is the same as delete followed by
unlink, the exact semantics are different. The former calls the
Tempfile's finalizer callback directly and can raise an Errno::EACCES,
while unlink never does.

In ruby 1.9, the Tempfile#close! method was changed to call unlink,
making the two APIs consistent. As a result, the begin-ensure block
added previously to fix #14964 was wrong.

Also, previously if the call to read failed, then the Tempfile would
not be closed and deleted until its finalizer ran.

This commit changes the wait_for_output method to close and unlink the
Tempfile in two steps. The unlink method will not raise an
Errno::EACCES in either ruby 1.8 or 1.9. It also changes the read
call to occur within the begin-ensure block, so that the Tempfile is
closed and unlinked as soon as we are done with it.

Paired-with: Andrew Parker <andy@puppetlabs.com>

Details

Provenance
Josh Cooper <josh@puppetlabs.com>Authored on
vanmeeuwenPushed on Jun 2 2015, 2:22 PM
Parents
rPU690c39bbe2c9: (Maint) Require the right file for md5
Branches
Unknown
Tags
Unknown

Event Timeline

Josh Cooper <josh@puppetlabs.com> committed rPU4c18d085e0b9: (#14964) Unlink Tempfiles consistently across different ruby versions (authored by Josh Cooper <josh@puppetlabs.com>).Jul 13 2012, 9:12 AM