net-ftp icon indicating copy to clipboard operation
net-ftp copied to clipboard

Issue with BufferedSSLSocket

Open JonathanTron opened this issue 1 year ago • 0 comments

Hi, I'm currently trying to update ftpd to work with recent ruby versions, and I'm having a hard time having the tests pass.

You can see my changes in https://github.com/wconrad/ftpd/pull/59.

To sumarize the problem, there are SSL tests failing 99% of the time on Linux VMs (amd64, Github Action). They never fail on my Mac (arm64) and fail sometimes when ran in docker (arm64, linux/amd64).

You can trigger the error by running bundle exec cucumber features/ftp_server/implicit_tls.feature, the result is always:

550 Connection reset by peer
       (Net::FTPPermError)

I found the issue goes away when I remove the changes from https://github.com/ruby/net-ftp/commit/f55e9d594533f97cb110797d3a7e59e936988c6e.

As far as I can tell, overriding rbuf_fill when shutdown has been called, prevents the current exchange from finishing properly.

I'm not sure if this change is still relevant today, there was no tests so I'm not even sure what it was supposed to fix exactly.

I found https://github.com/socketry/async-io/pull/61, referencing https://github.com/ruby/openssl/issues/609, and based on the changes applied, I tried to replace the rbuf_fill override with a simpler change in shutdown:

def shutdown(*args)
  @io.__send__(:stop)
end

This fixes the issue and seems to allow the tests to be fast (as opposed to no doing anything in shutdown for example).

Do you find this change reasonable? If you do, then I can submit a PR for it.

JonathanTron avatar Feb 05 '24 15:02 JonathanTron