Skip to content

Commit

Permalink
Skip some new specs for reading from a closed socket on Windows
Browse files Browse the repository at this point in the history
These specs fails with error:

```
Errno::EINVAL: Invalid argument - recvmsg(2)
```

on calling the following methods:

```ruby
client.recvmsg(10)
# or
client.recvmsg_nonblock(10)
```
  • Loading branch information
andrykonchin committed Jan 30, 2025
1 parent 0ba6deb commit 8126f9f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 27 deletions.
32 changes: 17 additions & 15 deletions library/socket/basicsocket/recvmsg_nonblock_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -263,26 +263,28 @@
end

ruby_version_is "3.3" do
it "returns nil on a closed stream socket" do
ready = false
platform_is_not :windows do
it "returns nil on a closed stream socket" do
ready = false

t = Thread.new do
client = @server.accept
t = Thread.new do
client = @server.accept

Thread.pass while !ready
client.recvmsg_nonblock(10)
ensure
client.close if client
end
Thread.pass while !ready
client.recvmsg_nonblock(10)
ensure
client.close if client
end

Thread.pass while t.status and t.status != "sleep"
t.status.should_not be_nil
Thread.pass while t.status and t.status != "sleep"
t.status.should_not be_nil

socket = TCPSocket.new('127.0.0.1', @port)
socket.close
ready = true
socket = TCPSocket.new('127.0.0.1', @port)
socket.close
ready = true

t.value.should be_nil
t.value.should be_nil
end
end
end
end
Expand Down
26 changes: 14 additions & 12 deletions library/socket/basicsocket/recvmsg_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,21 +229,23 @@
end

ruby_version_is "3.3" do
it "returns nil on a closed stream socket" do
t = Thread.new do
client = @server.accept
client.recvmsg(10)
ensure
client.close if client
end
platform_is_not :windows do
it "returns nil on a closed stream socket" do
t = Thread.new do
client = @server.accept
client.recvmsg(10)
ensure
client.close if client
end

Thread.pass while t.status and t.status != "sleep"
t.status.should_not be_nil
Thread.pass while t.status and t.status != "sleep"
t.status.should_not be_nil

socket = TCPSocket.new('127.0.0.1', @port)
socket.close
socket = TCPSocket.new('127.0.0.1', @port)
socket.close

t.value.should be_nil
t.value.should be_nil
end
end
end
end
Expand Down

0 comments on commit 8126f9f

Please sign in to comment.