aboutsummaryrefslogtreecommitdiffstats
path: root/test/socket
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-21 00:55:13 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-21 00:55:13 +0000
commitd691a28d914e7e5152b7dc3f47da1baaf684fbfb (patch)
tree9d7dba4c95dd0e2afe4a5623e9a522e1cf99fcb9 /test/socket
parentf404c1022c8389c20569c139f12bbace12ed82ad (diff)
downloadruby-d691a28d914e7e5152b7dc3f47da1baaf684fbfb.tar.gz
socket: sendmsg/recvmsg only retries blocking on errors
* ext/socket/ancdata.c (bsock_sendmsg_internal): only retry on error (bsock_recvmsg_internal): ditto * test/socket/test_unix.rb: test above for infinite loop git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45066 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/socket')
-rw-r--r--test/socket/test_unix.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/socket/test_unix.rb b/test/socket/test_unix.rb
index ada614c23f..a6879bbfe4 100644
--- a/test/socket/test_unix.rb
+++ b/test/socket/test_unix.rb
@@ -5,6 +5,7 @@ end
require "test/unit"
require "tempfile"
+require "timeout"
require "tmpdir"
require "thread"
require "io/nonblock"
@@ -369,6 +370,28 @@ class TestSocket_UNIXSocket < Test::Unit::TestCase
s2.close if s2
end
+ def test_dgram_pair_sendrecvmsg_errno_set
+ s1, s2 = to_close = UNIXSocket.pair(Socket::SOCK_DGRAM)
+ pipe = IO.pipe
+ to_close.concat(pipe)
+ set_errno = lambda do
+ begin
+ pipe[0].read_nonblock(1)
+ fail
+ rescue => e
+ assert(IO::EAGAINWaitReadable === e)
+ end
+ end
+ Timeout.timeout(10) do
+ set_errno.call
+ assert_equal(2, s1.sendmsg("HI"))
+ set_errno.call
+ assert_equal("HI", s2.recvmsg[0])
+ end
+ ensure
+ to_close.each(&:close) if to_close
+ end
+
def test_epipe # [ruby-dev:34619]
s1, s2 = UNIXSocket.pair
s1.shutdown(Socket::SHUT_WR)