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

Rubygems does not terminate on failed file lock when not superuser #1582

Merged
merged 6 commits into from
May 30, 2016
Merged

Rubygems does not terminate on failed file lock when not superuser #1582

merged 6 commits into from
May 30, 2016

Conversation

duckinator
Copy link
Member

Description:

Supersedes PR #1536.

Fixes issue #1535.

Tasks:

  • Describe the problem / feature
  • Write tests
  • Write code to solve the problem
  • Get code review from coworkers / friends
  • Squash commits

I will abide by the code of conduct.

@duckinator
Copy link
Member Author

As a note for anyone looking at this, this still needs tests.

@duckinator
Copy link
Member Author

Looking at the error Travis CI returns: Line 841 is a comment. I have no idea what it's doing.

I am completely lost as to what the hell Appveyor is doing.

@segiddins
Copy link
Member

According to GH, line 841 is rescue *READ_BINARY_ERRORS

@duckinator
Copy link
Member Author

Okay, something was up locally. That's what I'm seeing locally now, too.

As for the actual issue, it looks like READ_BINARY_ERRORS is nil?

irb(main):001:0>   READ_BINARY_ERRORS = begin
irb(main):002:1*     read_binary_errors = [Errno::EACCES]
<inary_errors << Errno::ENOTSUP if Errno.const_defined?(:ENOTSUP)
irb(main):004:1>   end.freeze
=> nil
irb(main):005:0> READ_BINARY_ERRORS
=> nil
irb(main):006:0>

@duckinator
Copy link
Member Author

duckinator commented Apr 20, 2016

Oh! I see what the issue is. I need to return read_binary_errors right before the end.freeze, or it'll return nil on 1.8.7.

@duckinator
Copy link
Member Author

Well, that's Travis errors fixed. Appveyor failure is caused by #1586.

io.flock(File::LOCK_EX)
begin
io.flock(File::LOCK_EX)
rescue Errno::ENOTSUP
Copy link
Member

Choose a reason for hiding this comment

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

this will fail on 1.8.7 as well, no?

Copy link
Member Author

Choose a reason for hiding this comment

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

looks like it, yeah.

Copy link
Member Author

Choose a reason for hiding this comment

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

@segiddins the issue I'm running into here is since it only has one class, if I use the approach that was used for Gem.read_binary, then on 1.8.7 it'll be equivalent to this:

begin
  io.flock(File::LOCK_EX)
rescue
end

which seems... bad?

Any idea how to approach this?

@duckinator
Copy link
Member Author

duckinator commented Apr 22, 2016

Rebased, since Appveyor builds have been fixed on master.

@duckinator
Copy link
Member Author

@segiddins do you have any thoughts on how to approach testing this? I'm having trouble wrapping my head around what exactly needs testing; it seems like 2-3 things need tests for both read_binary and write_binary, but I'm not quite sure what they are.

open(path, 'wb') do |io|
begin
io.flock(File::LOCK_EX)
rescue Errno::ENOTSUP
Copy link
Member

Choose a reason for hiding this comment

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

couldn't ENOTSUP be undefined here as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

@segiddins
Copy link
Member

this looks good, other than the failing specs

@duckinator
Copy link
Member Author

duckinator commented May 25, 2016

Behold, the mighty question mark, breaker of tests.

(I have to begrudgingly admit I committed without running the tests locally...)

@duckinator
Copy link
Member Author

@segiddins specs are fixed, btw.

@segiddins
Copy link
Member

@HoMr r+
Thanks @duckinator !

@duckinator
Copy link
Member Author

@segiddins you @'d @HoMr instead of @homu.

@segiddins
Copy link
Member

@homu r+
😬

@homu
Copy link
Contributor

homu commented May 30, 2016

📌 Commit 23d8e9c has been approved by segiddins

homu added a commit that referenced this pull request May 30, 2016
Rubygems does not terminate on failed file lock when not superuser

# Description:

Supersedes PR #1536.

Fixes issue #1535.

# Tasks:

- [x] Describe the problem / feature
- [ ] Write tests
- [x] Write code to solve the problem
- [ ] Get code review from coworkers / friends
- [ ] [Squash commits](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html)

I will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md).
@homu
Copy link
Contributor

homu commented May 30, 2016

⌛ Testing commit 23d8e9c with merge 6c6d268...

@homu
Copy link
Contributor

homu commented May 30, 2016

☀️ Test successful - status

@homu homu merged commit 23d8e9c into rubygems:master May 30, 2016
@duckinator duckinator deleted the fix-issue-1535 branch November 28, 2017 14:57
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.

6 participants