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

Actually release Windows for_fd fixes #5829

Closed
headius opened this issue Aug 12, 2019 · 2 comments
Closed

Actually release Windows for_fd fixes #5829

headius opened this issue Aug 12, 2019 · 2 comments

Comments

@headius
Copy link
Member

@headius headius commented Aug 12, 2019

For #5774 @byteit101 provided fixes for both jnr-enxio and JRuby. We merged the fixes for jnr-enxio and the fixes for JRuby, but never released a new enxio nor pointed JRuby at the fixed version.

We'll have to spin this in 9.2.9.

@headius headius added this to the JRuby 9.2.9.0 milestone Aug 12, 2019
@headius headius closed this in dd3a55c Aug 12, 2019
@headius

This comment has been minimized.

Copy link
Member Author

@headius headius commented Aug 12, 2019

I have requested tests for this behavior so we can verify it's working (and stays working).

@byteit101

This comment has been minimized.

Copy link
Member

@byteit101 byteit101 commented Aug 13, 2019

non-python-compliant test that might like some cleanup:

module WinIoTestHelpMod
    extend FFI::Library
    ffi_lib 'kernel32'
    ffi_convention :stdcall

    GENERIC_READ  = 0x80000000
    GENERIC_WRITE = 0x40000000
    OPEN_EXISTING = 3


    attach_function :CreateFileA,     [:pointer, :uint32, :uint32, :pointer, :uint32, :uint32, :pointer], :pointer, blocking: true
	end
	  module WinCTestHelpMod
    extend FFI::Library
    ffi_lib 'msvcrt'
    ffi_convention :stdcall

    attach_function :_open_osfhandle,     [:pointer, :int], :int, blocking: true
  end
class WinIOTestHelp
	def self.open(file)
	    flags = WinIoTestHelpMod::GENERIC_READ | WinIoTestHelpMod::GENERIC_WRITE
    	@fd = WinIoTestHelpMod.CreateFileA(file, flags, 0, nil, WinIoTestHelpMod::OPEN_EXISTING, 0, nil)
	    err = FFI.errno
	    if err != 0
    	  raise "ffi error: #{err}"
		end
		WinCTestHelpMod._open_osfhandle @fd, File::RDWR
	end
end

describe "fd" do
FILENAME=".atestfile"
  before do
   File.write(FILENAME, "Some contents")
  end

  after do
   File.delete(FILENAME)
  end

	it "should be reopenable" do # fails .7, fixed .8, 9. Works on all systems, no enxio codepath
		File.open(FILENAME, "rb") do |f|
			fno = f.fileno
			expect(fno).to be > 2
			expect(fno).to be < 4096
			expect(f.fileno).to eq fno
			expect(f.read(2)).to eq "So"
			io = IO.for_fd(fno)
			expect(io.read(2)).to eq "me"
		end
	end
	

	it "should support sysopen" do # Fails .7, fixed .8, .9. No ENXIO codepath, works on all systems
		fno = File::sysopen(FILENAME, "rb")
			expect(fno).to be > 2
			expect(fno).to be < 4096
			io = IO.for_fd(fno)
			expect(io.read(2)).to eq "So"
			io.close
		
	end
	it "should support win open" do # Fails .7, .8, fixed .9. Requires ENXIO codepath. Windows only
		fno = WinIOTestHelp.open(FILENAME)
			expect(fno).to be > 2
			expect(fno).to be < 4096
			io = IO.for_fd(fno)
			expect(io.read(2)).to eq "So"
		
			io.close
	end
end

Expected .7 error: 0/3 pass
Expected .8 error: 2/3 pass. large stack trace+ permisison denied (file stil open, locked)
Tested .9-snapshot: 3/3 pass

Adithya-copart added a commit to Adithya-copart/jruby that referenced this issue Aug 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.