Project

General

Profile

Actions

Bug #13491

closed

MinGW 58400 - TestSocket_BasicSocket#test_read_write_nonblock

Added by MSP-Greg (Greg L) over 7 years ago. Updated over 7 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.5.0dev (2017-04-21 trunk 58426) [x64-mingw32]
[ruby-core:80817]

Description

The test TestSocket_BasicSocket#test_read_write_nonblock was recently add via 58400 / c32fc82.

On a MinGW build, it fails. The following change at line 197 allows a MinGW build to pass.

      case r = ssock.read_nonblock(16384, buf, exception: false)
      when String
        next
      when nil
        break
      else
-       flunk "unexpected read_nonblock return: #{r.inspect}"
+       flunk "unexpected read_nonblock return: #{r.inspect}" unless set_nb
      end while true

See GitHub PR 1595

Updated by normalperson (Eric Wong) over 7 years ago

wrote:

The test TestSocket_BasicSocket#test_read_write_nonblock was recently add via 58400 / c32fc82.

On a MinGW build, it fails. The following change at line 197 allows a MinGW build to pass.

      case r = ssock.read_nonblock(16384, buf, exception: false)
      when String
        next
      when nil
        break
      else
-       flunk "unexpected read_nonblock return: #{r.inspect}"
+       flunk "unexpected read_nonblock return: #{r.inspect}" unless set_nb
      end while true

Oops, but wouldn't checking for :wait_readable be more correct?
Can you try the following, instead?

diff --git a/test/socket/test_basicsocket.rb b/test/socket/test_basicsocket.rb
index 0b13a7f1af..4d11521e9e 100644
--- a/test/socket/test_basicsocket.rb
+++ b/test/socket/test_basicsocket.rb
@@ -193,6 +193,9 @@ def test_read_write_nonblock
next
when nil
break

  •  when :wait_readable
    
  •    IO.select([ssock], nil, nil, 10) or
    
  •      flunk 'socket did not become readable'
    

else
flunk "unexpected read_nonblock return: #{r.inspect}"
end while true

Thanks.

Updated by normalperson (Eric Wong) over 7 years ago

Can you try r58437? I made it call IO.select on :wait_readable
instead of using your change.
Thanks.

Updated by MSP-Greg (Greg L) over 7 years ago

normalperson (Eric Wong) wrote:

Can you try r58437?

Works. I guess I was staring at the case statement, I should have added the test for :wait_readable. I tried IO.select, but I left of the timeout...

Thank you. I'll close the PR and this can be closed.

Updated by usa (Usaku NAKAMURA) over 7 years ago

  • Status changed from Open to Closed

I got same error, too.
And it seems that r58437 has fixed it.
I still doubt that there is something wrong with IO#read_nonblock on Windows, but, about this issue, can be closed.

Updated by normalperson (Eric Wong) over 7 years ago

wrote:

I got same error, too.
And it seems that r58437 has fixed it.
I still doubt that there is something wrong with IO#read_nonblock on Windows, but, about this issue, can be closed.

Nothing wrong, just different behavior and I was sloppy.
I have encountered similar socket behavior differences before,
even between Linux and *BSD.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0