* ext/socket/socket.c (socket_s_ip_address_list): drop inactive

adapters.

	* test/socket/test_{nonblock,addrinfo,socket}.rb: skip some tests on
	  Windows.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24173 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
usa 2009-07-17 13:40:59 +00:00
Родитель 3d704802dd
Коммит 229b4e4c37
5 изменённых файлов: 33 добавлений и 5 удалений

Просмотреть файл

@ -1,3 +1,12 @@
Fri Jul 17 22:37:22 2009 NAKAMURA Usaku <usa@ruby-lang.org>
* ext/socket/socket.c (socket_s_ip_address_list): drop inactive
adapters.
* test/socket/test_{nonblock,addrinfo,socket}.rb: skip some tests on
Windows.
[ruby-core:23051]
Fri Jul 17 22:29:21 2009 NAKAMURA Usaku <usa@ruby-lang.org>
* ext/readline/readline.c (Init_readline): use rl_catch_sigwinch only

Просмотреть файл

@ -1693,7 +1693,7 @@ socket_s_ip_address_list(VALUE self)
DWORD dummy9;
DWORD dummy10;
DWORD IfType;
int dummy11;
int OperStatus;
DWORD dummy12;
DWORD dummy13[16];
void *dummy14;
@ -1733,12 +1733,22 @@ socket_s_ip_address_list(VALUE self)
for (; adapters; adapters = adapters->Next) {
ip_adapter_unicast_address_t *uni;
ip_adapter_anycast_address_t *any;
if (adapters->OperStatus != 1) /* 1 means IfOperStatusUp */
continue;
for (uni = adapters->FirstUnicastAddress; uni; uni = uni->Next) {
#ifndef INET6
if (uni->Address.lpSockaddr->sa_family == AF_INET)
#else
if (IS_IP_FAMILY(uni->Address.lpSockaddr->sa_family))
#endif
rb_ary_push(list, sockaddr_obj(uni->Address.lpSockaddr));
}
for (any = adapters->FirstAnycastAddress; any; any = any->Next) {
#ifndef INET6
if (any->Address.lpSockaddr->sa_family == AF_INET)
#else
if (IS_IP_FAMILY(any->Address.lpSockaddr->sa_family))
#endif
rb_ary_push(list, sockaddr_obj(any->Address.lpSockaddr));
}
}

Просмотреть файл

@ -317,6 +317,7 @@ class TestSocketAddrinfo < Test::Unit::TestCase
ai = Addrinfo.tcp("0.0.0.0", 4649).family_addrinfo("127.0.0.1", 80)
assert_equal(["127.0.0.1", 80], ai.ip_unpack)
assert_equal(Socket::SOCK_STREAM, ai.socktype)
return unless Addrinfo.respond_to?(:unix)
ai = Addrinfo.unix("/testdir/sock").family_addrinfo("/testdir/sock2")
assert_equal("/testdir/sock2", ai.unix_path)
assert_equal(Socket::SOCK_STREAM, ai.socktype)

Просмотреть файл

@ -196,6 +196,8 @@ class TestSocketNonblock < Test::Unit::TestCase
loop {
c.sendmsg_nonblock("a" * 100000)
}
rescue NotImplementedError
skip "sendmsg not implemented on this platform."
rescue Errno::EWOULDBLOCK
assert_kind_of(IO::WaitWritable, $!)
end
@ -206,6 +208,8 @@ class TestSocketNonblock < Test::Unit::TestCase
tcp_pair {|c, s|
begin
c.recvmsg_nonblock(4096)
rescue NotImplementedError
skip "sendmsg not implemented on this platform."
rescue Errno::EWOULDBLOCK
assert_kind_of(IO::WaitReadable, $!)
end

Просмотреть файл

@ -36,19 +36,22 @@ class TestSocket < Test::Unit::TestCase
def test_initialize
Socket.open(Socket::AF_INET, Socket::SOCK_STREAM, 0) {|s|
s.bind(Socket.sockaddr_in(0, "127.0.0.1"))
addr = s.getsockname
assert_nothing_raised { Socket.unpack_sockaddr_in(addr) }
assert_raise(ArgumentError) { Socket.unpack_sockaddr_un(addr) }
assert_raise(ArgumentError, NoMethodError) { Socket.unpack_sockaddr_un(addr) }
}
Socket.open("AF_INET", "SOCK_STREAM", 0) {|s|
s.bind(Socket.sockaddr_in(0, "127.0.0.1"))
addr = s.getsockname
assert_nothing_raised { Socket.unpack_sockaddr_in(addr) }
assert_raise(ArgumentError) { Socket.unpack_sockaddr_un(addr) }
assert_raise(ArgumentError, NoMethodError) { Socket.unpack_sockaddr_un(addr) }
}
Socket.open(:AF_INET, :SOCK_STREAM, 0) {|s|
s.bind(Socket.sockaddr_in(0, "127.0.0.1"))
addr = s.getsockname
assert_nothing_raised { Socket.unpack_sockaddr_in(addr) }
assert_raise(ArgumentError) { Socket.unpack_sockaddr_un(addr) }
assert_raise(ArgumentError, NoMethodError) { Socket.unpack_sockaddr_un(addr) }
}
end
@ -254,10 +257,11 @@ class TestSocket < Test::Unit::TestCase
begin
ip_addrs = Socket.ip_address_list
rescue NotImplementedError
return
skip "Socket.ip_address_list not implemented"
end
Socket.udp_server_sockets(0) {|sockets|
skip "need sendmsg and recvmsg" unless sockets.respond_to?(:sendmsg)
famlies = {}
sockets.each {|s| famlies[s.local_address.afamily] = true }
ip_addrs.reject! {|ai| !famlies[ai.afamily] }