1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
| | require 'test/unit'
require 'fcntl'
require 'io/nonblock'
$-w = true
require 'kgio'
class TestAcceptFlags < Test::Unit::TestCase
def test_accept_flags
@host = ENV["TEST_HOST"] || '127.0.0.1'
@srv = Kgio::TCPServer.new(@host, 0)
@port = @srv.addr[1]
client = TCPSocket.new(@host, @port)
accepted = @srv.kgio_accept(nil, Kgio::SOCK_NONBLOCK)
assert_instance_of Kgio::Socket, accepted
flags = accepted.fcntl(Fcntl::F_GETFD)
assert_equal 0, flags & Fcntl::FD_CLOEXEC
assert_nil client.close
assert_nil accepted.close
client = TCPSocket.new(@host, @port)
accepted = @srv.kgio_accept(nil, Kgio::SOCK_CLOEXEC)
assert_instance_of Kgio::Socket, accepted
flags = accepted.fcntl(Fcntl::F_GETFD)
assert_equal Fcntl::FD_CLOEXEC, flags & Fcntl::FD_CLOEXEC
assert_nil client.close
assert_nil accepted.close
client = TCPSocket.new(@host, @port)
accepted = @srv.kgio_accept(nil, Kgio::SOCK_CLOEXEC|Kgio::SOCK_NONBLOCK)
assert_instance_of Kgio::Socket, accepted
flags = accepted.fcntl(Fcntl::F_GETFD)
assert_equal Fcntl::FD_CLOEXEC, flags & Fcntl::FD_CLOEXEC
assert_nil client.close
assert_nil accepted.close
client = TCPSocket.new(@host, @port)
accepted = @srv.kgio_accept(nil, Kgio::SOCK_CLOEXEC|Kgio::SOCK_NONBLOCK)
assert_instance_of Kgio::Socket, accepted
flags = accepted.fcntl(Fcntl::F_GETFD)
assert_equal Fcntl::FD_CLOEXEC, flags & Fcntl::FD_CLOEXEC
assert_nil client.close
assert_nil accepted.close
end
end
|