summaryrefslogtreecommitdiff
path: root/test/socket
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-18 18:43:15 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-18 18:43:15 +0000
commit18afbc891c3ac8d21b7d93a2d8ad76c2f536956d (patch)
treecccfa88aaecbe132e117d95b94d243ec4c113667 /test/socket
parent2485ed517745088bf2b26707f2a66217b778d4f3 (diff)
* ext/socket/ancdata.c (ancillary_rights): new method.
(make_io_for_rights): new function to allocate IOs for FDs in SCM_RIGHTS message. (bsock_recvmsg_internal): use make_io_for_rights. So the FDs can be closed by GC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22426 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/socket')
-rw-r--r--test/socket/test_unix.rb17
1 files changed, 9 insertions, 8 deletions
diff --git a/test/socket/test_unix.rb b/test/socket/test_unix.rb
index 6e822dbc36..e4c86f2912 100644
--- a/test/socket/test_unix.rb
+++ b/test/socket/test_unix.rb
@@ -53,7 +53,7 @@ class TestSocket_UNIXSocket < Test::Unit::TestCase
recv_io_ary = []
ctls.each {|ctl|
next if ctl.level != Socket::SOL_SOCKET || ctl.type != Socket::SCM_RIGHTS
- recv_io_ary.concat ctl.data.unpack("i!*").map {|fd| IO.new(fd) }
+ recv_io_ary.concat ctl.rights
}
assert_equal(send_io_ary.length, recv_io_ary.length)
send_io_ary.length.times {|i|
@@ -126,13 +126,14 @@ class TestSocket_UNIXSocket < Test::Unit::TestCase
assert_instance_of(Addrinfo, srcaddr)
assert_instance_of(Array, ctls)
assert_equal(1, ctls.length)
- assert_instance_of(Socket::AncillaryData, ctls[0])
- assert_equal(Socket::SOL_SOCKET, ctls[0].level)
- assert_equal(Socket::SCM_RIGHTS, ctls[0].type)
- assert_instance_of(String, ctls[0].data)
- fd, rest = ctls[0].data.unpack("i!a*")
- assert_equal("", rest)
- r2 = IO.new(fd)
+ ctl = ctls[0]
+ assert_instance_of(Socket::AncillaryData, ctl)
+ assert_equal(Socket::SOL_SOCKET, ctl.level)
+ assert_equal(Socket::SCM_RIGHTS, ctl.type)
+ assert_instance_of(String, ctl.data)
+ ios = ctl.rights
+ assert_equal(1, ios.length)
+ r2 = ios[0]
begin
assert(File.identical?(r1, r2))
ensure