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

9k fail ftp on Windows #3189

Closed
yousuketto opened this issue Jul 27, 2015 · 6 comments
Closed

9k fail ftp on Windows #3189

yousuketto opened this issue Jul 27, 2015 · 6 comments
Labels
Milestone

Comments

@yousuketto
Copy link
Contributor

I have used jruby 9.0.0.0 on Windows7.
9.0.0.0 fail ftp on Windows7, but succeed on MacOS.
jruby 1.7.20.1 succeed on Windows7.

ex)

require 'net/ftp'
require 'uri'

FTP_URI = URI.parse('ftp://user_name:user_password@myftp-server.example.com/')

list = Net::FTP.open(FTP_URI.host, FTP_URI.user, FTP_URI.password) do |ftp|
  ftp.passive = true
  ftp.list('*')
end

puts list
C:\workspace>jruby -v
jruby 9.0.0.0 (2.2.2) 2015-07-21 e10ec96 Java HotSpot(TM) 64-Bit Server VM 25.31-b07 on 1.8.0_31-b13 +jit [Windows 7-amd64]

C:\workspace>jruby example.rb
IOError: not opened for reading
        read_nonblock at org/jruby/RubyIO.java:2768
            rbuf_fill at C:/workspace/jruby-9.0.0.0/lib/ruby/stdlib/net/protocol.rb:153
                 read at C:/workspace/jruby-9.0.0.0/lib/ruby/stdlib/net/protocol.rb:104
                 read at C:/workspace/jruby-9.0.0.0/lib/ruby/stdlib/net/ftp.rb:1099
   block in retrlines at C:/workspace/jruby-9.0.0.0/lib/ruby/stdlib/net/ftp.rb:526
          with_binary at C:/workspace/jruby-9.0.0.0/lib/ruby/stdlib/net/ftp.rb:199
   block in retrlines at C:/workspace/jruby-9.0.0.0/lib/ruby/stdlib/net/ftp.rb:516
      mon_synchronize at C:/workspace/jruby-9.0.0.0/lib/ruby/stdlib/monitor.rb:211
            retrlines at C:/workspace/jruby-9.0.0.0/lib/ruby/stdlib/net/ftp.rb:515
                 list at C:/workspace/jruby-9.0.0.0/lib/ruby/stdlib/net/ftp.rb:767
  block in example.rb at example.rb:8
                 open at C:/workspace/jruby-9.0.0.0/lib/ruby/stdlib/net/ftp.rb:135
                <top> at example.rb:6
@boomerang
Copy link

Same problem for me!

@enebo enebo added this to the JRuby 9.0.1.0 milestone Aug 13, 2015
@enebo enebo added the core label Aug 13, 2015
@headius
Copy link
Member

headius commented Aug 17, 2015

Some notes from investigation so far:

  • The sequence of commands sent on Windows seems to differ greatly from those sent on UNIX. I'm not sure why this is, but it could be due to Windows defaulting to crlf in some cases?
  • The various errors I've seen usually mask another error. In my case, the connection appears to be reset around the time it tries to send PASV. The subsequent read of PASV result string fails and then cascades through several levels of ensures that all try to clean up the socket. Since the socket is now closed, they all fail in interesting ways.

I'm going to need to correlate the order of events on both unix and windows so I'm getting a VM up and running.

@headius
Copy link
Member

headius commented Aug 18, 2015

Bleh. Spent most of the day debugging the wrong thing. Windows Firewall was actively killing the connection immediately after client sent PASV, which then cascaded out as a series of wrong errors.

I now see the reported error and will continue to investigate.

@headius
Copy link
Member

headius commented Aug 18, 2015

Ok, of course the actual bug took about 5 minutes to investigate. It looks like when the FTP library attempts to shut down write on the passive data connection, it's actually shutting down read. Then it proceeds to try to read the data and kablooey.

I'm a bit confused why this doesn't break on OS X.

@headius
Copy link
Member

headius commented Aug 18, 2015

Now all things are clear.

The constants on Windows for IO shutdown were being defined incorrectly. Instead of read = 0, write = 1, readwrite = 2, it was read = 1, write = 2, readwrite = 4. As a result, closing the write stream ended up closing everything.

This is likely the cause of other similar errors. It is fixed in jnr-constants 0.9.0, and JRuby 9.0.1.0 will ship with that dependency.

@headius
Copy link
Member

headius commented Aug 18, 2015

And closing the loop on 1.7 passing this... not until 9k did we define these constants via jnr-constants, so the bad fake values never affected 1.7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants