Граф коммитов

197 Коммитов

Автор SHA1 Сообщение Дата
odaira bebb4e9dea test/socket/test_unix.rb (TestSocket_UNIXSocket#test_too_long_path): sockaddr_un.sun_path in AIX is defined as char[1024], so "a" * 300 is not too long. "a" * 3000 would be enough.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47785 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-04 07:11:54 +00:00
akr 4bf480b7d5 Suppress warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-28 22:59:07 +00:00
akr eb9f446ebf * ext/socket/unixsocket.c (rsock_init_unixsock): Open a socket
after path length check.
  This fixes a fd leak by TestSocket_UNIXSocket#test_too_long_path.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-28 15:42:09 +00:00
nobu 391cad0cb3 test_socket.rb: ignore interface without address
* test/socket/test_socket.rb (test_udp_server): ignore interface
  with no address assigned.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46204 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-28 05:11:05 +00:00
naruse c3ebc82832 use Socket.getifaddrs to show interface names and so on
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46172 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-27 12:29:08 +00:00
akr e8e6ecdef0 test_udp_server don't test IPv6 link-local addresses.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-24 11:12:10 +00:00
akr bd4fdb714f Use Etc.uname instead of uname command invocation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46001 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-18 08:45:37 +00:00
normal d691a28d91 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
2014-02-21 00:55:13 +00:00
hsbt 28b3d20ba9 * test/socket/test_socket.rb: unix socket is required by test case.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45037 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-18 14:23:30 +00:00
hsbt 93156392dd * test/socket/test_addrinfo.rb: remove unused variables.
* test/socket/test_nonblock.rb: ditto.
* test/socket/test_socket.rb: ditto.
* test/socket/test_unix.rb: ditto.
* test/testunit/test_parallel.rb: ditto.
* test/webrick/test_filehandler.rb: ditto.
* test/xmlrpc/test_features.rb: ditto.
* test/zlib/test_zlib.rb: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45034 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-18 12:05:09 +00:00
akr 779a630aee * ext/socket/option.c: Use "int" for IP_MULTICAST_LOOP and
IP_MULTICAST_TTL on Mac OS X.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44667 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-20 19:32:03 +00:00
akr 5af92f6369 add a test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44666 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-20 15:51:33 +00:00
akr 4fd53e476e * ext/socket/lib/socket.rb: Don't test $! in "ensure" clause because
it may be set before the body.
  Reported by ko1 and mrkn.  [ruby-core:59088] [Bug #9247]

* lib/cgi/core.rb: Ditto.

* lib/drb/ssl.rb: Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44184 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-13 16:11:12 +00:00
tenderlove 988ca60565 * io.c (io_read_nonblock): support non-blocking reads without raising
exceptions. As in: `io.read_nonblock(size, exception: false)`
  [ruby-core:38666] [Feature #5138]
* ext/openssl/ossl_ssl.c (ossl_ssl_read_internal): ditto
* ext/stringio/stringio.c (strio_sysread): ditto
* io.c (rb_io_write_nonblock): support non-blocking writes without
  raising an exception.
* ext/openssl/ossl_ssl.c (ossl_ssl_write_internal): ditto
* test/openssl/test_pair.rb (class OpenSSL): tests
* test/ruby/test_io.rb (class TestIO): ditto
* test/socket/test_nonblock.rb (class TestSocketNonblock): ditto
* test/stringio/test_stringio.rb (class TestStringIO): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-26 22:41:44 +00:00
akr e9c0450960 * test/socket/test_tcp.rb (test_initialize_failure): Use EADDRNOTAVAIL
to test an error message generated by bind() failure.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42057 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-19 03:35:53 +00:00
naruse 7c467109dd Use server_port for Windows
fix r41686 [Bug #8574]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41802 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-05 18:38:17 +00:00
akr a5fcce2820 * ext/socket/ipsocket.c (init_inetsock_internal): Don't use local
addresses which address family is different to remote address.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41686 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-28 03:16:07 +00:00
akr 3a81008354 * test/socket/test_udp.rb: Close sockets explicitly.
Don't use fixed port number.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41638 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-26 03:09:54 +00:00
ayumin 233f7d09e3 * test/socket/test_sockopt.rb: change test name. follow r41037.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41040 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-02 16:37:14 +00:00
naruse aa26e9d9c0 follow r41034
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41037 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-02 15:59:18 +00:00
naruse a78e45b5fe * ext/socket/option.c (sockopt_s_byte): constructor of the sockopt
whose value's is byte.

* ext/socket/option.c (sockopt_byte): getter for above.

* ext/socket/option.c (inspect_byte): inspect for above.

* ext/socket/option.c (sockopt_s_ip_multicast_loop): constructor of
  the sockopt whose optname is IP_MULTICAST_LOOP.

* ext/socket/option.c (sockopt_ip_multicast_loop): getter for above.

* ext/socket/option.c (sockopt_s_ip_multicast_ttl): constructor of
  the sockopt whose optname is IP_MULTICAST_TTL.

* ext/socket/option.c (sockopt_ip_multicast_ttl): getter for above.

* ext/socket/option.c (sockopt_inspect): use above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-31 17:37:55 +00:00
akr b323d7d54c * ext/socket: New method, Socket.getifaddrs, implemented.
[ruby-core:54777] [Feature #8368]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40639 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-11 08:32:26 +00:00
akr adb575e21e * ext/socket/ancdata.c (bsock_sendmsg_internal): Always set
controls_num to raise NotImplementedError appropriately.
  (bsock_recvmsg_internal): Raise NotImplementedError if
  :scm_rights=>true is given on platforms which don't have
  4.4BSD style control message.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40624 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-09 11:48:29 +00:00
nobu fa93be2f05 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40196 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-08 20:27:01 +00:00
headius 0626d9b91c Fix #6154 by introducing new EAGAIN/EWOULDBLOCK/EINPROGRESS
subclasses that include WaitReadable or WaitWritable rather than
extending them into the exception object each time.

* error.c: Capture EGAIN, EWOULDBLOCK, EINPROGRESS exceptions and
  export them for use in WaitReadable/Writable exceptions.
* io.c: Create versions of EAGAIN, EWOULDBLOCK, EINPROGRESS that
  include WaitReadable and WaitWritable. Add rb_readwrite_sys_fail
  for nonblocking failures using those exceptions. Use that
  function in io_getpartial and io_write_nonblock instead of
  rb_mod_sys_fail
* ext/openssl/ossl_ssl.c: Add new SSLError subclasses that include
  WaitReadable and WaitWritable. Use those classes for
  write_would_block and read_would_block instead of rb_mod_sys_fail.
* ext/socket/ancdata.c: Use rb_readwrite_sys_fail instead of
  rb_mod_sys_fail in bsock_sendmsg_internal and
  bsock_recvmsg_internal.
* ext/socket/init.c: Use rb_readwrite_sys_fail instead of
  rb_mod_sys_fail in rsock_s_recvfrom_nonblock and
  rsock_s_connect_nonblock.
* ext/socket/socket.c: Use rb_readwrite_sys_fail instead of
  rb_mod_sys_fail in sock_connect_nonblock.
* include/ruby/ruby.h: Export rb_readwrite_sys_fail for use instead
  of rb_mod_sys_fail. Introduce new constants RB_IO_WAIT_READABLE and
  RB_IO_WAIT_WRITABLE for first arg to rb_readwrite_sys_fail.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-08 19:58:55 +00:00
akr cb302bf351 * ext/socket/rubysocket.h (SockAddrStringValueWithAddrinfo): New macro.
(rsock_sockaddr_string_value_with_addrinfo): New declaration.
  (rsock_addrinfo_inspect_sockaddr): Ditto.
  (rsock_sys_fail_addrinfo): Ditto.
  (rsock_sys_fail_sockaddr_or_addrinfo): Ditto.

* ext/socket/raddrinfo.c (rsock_addrinfo_inspect_sockaddr): Renamed
  from addrinfo_inspect_sockaddr and exported.
  (rsock_sockaddr_string_value_with_addrinfo): New function to obtain
  string and possibly addrinfo object.

* ext/socket/socket.c (rsock_sys_fail_sockaddr): Don't use
  rsock_sys_fail_host_port which is IP dependent.  Invoke
  rsock_sys_fail_addrinfo.
  (rsock_sys_fail_addrinfo): New function using
  rsock_addrinfo_inspect_sockaddr.
  (rsock_sys_fail_addrinfo_or_sockaddr): New function.
  (sock_connect): Use SockAddrStringValueWithAddrinfo and
  rsock_sys_fail_addrinfo_or_sockaddr.
  (sock_connect_nonblock): Ditto.
  (sock_bind): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40154 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-06 05:50:42 +00:00
akr d933fb2296 * ext/socket: Improve socket exception message to show socket address.
[ruby-core:45617] [Feature #6583] proposed Eric Hodel.

* ext/socket/rubysocket.h (rsock_sys_fail_host_port): Declared.
  (rsock_sys_fail_path): Ditto.
  (rsock_sys_fail_sockaddr): Ditto.

* ext/socket/udpsocket.c (udp_connect): Use rsock_sys_fail_host_port.
  (udp_bind): Ditto.
  (udp_send): Ditto.

* ext/socket/init.c (rsock_init_sock): Specify a string for rb_sys_fail
  argument.
  (make_fd_nonblock): Ditto.
  (rsock_s_accept): Ditto.

* ext/socket/ipsocket.c (init_inetsock_internal): Use
  rsock_sys_fail_host_port.

* ext/socket/socket.c (rsock_sys_fail_host_port): Defined.
  (rsock_sys_fail_path): Ditto.
  (rsock_sys_fail_sockaddr): Ditto.
  (setup_domain_and_type): Use rsock_sys_fail_sockaddr.
  (sock_connect_nonblock): Ditto.
  (sock_bind): Ditto.
  (sock_gethostname): Specify a string for rb_sys_fail argument.
  (socket_s_ip_address_list): Ditto.

* ext/socket/basicsocket.c (bsock_shutdown): Specify a string for
  rb_sys_fail argument.
  (bsock_setsockopt): Use rsock_sys_fail_path.
  (bsock_getsockopt): Ditto.
  (bsock_getpeereid): Refine the argument for rb_sys_fail.

* ext/socket/unixsocket.c (rsock_init_unixsock): Use
  rsock_sys_fail_path.
  (unix_path): Ditto.
  (unix_send_io): Ditto.
  (unix_recv_io): Ditto.
  (unix_addr): Ditto.
  (unix_peeraddr): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40149 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-06 02:39:44 +00:00
shugo 4ccfb2743f * ext/socket/raddrinfo.c (rsock_unix_sockaddr_len): return
sizeof(sa_familiy_t) if path is empty.  see "Autobind Feature" in
  unix(7) for details.

* ext/socket/lib/socket.rb (unix_socket_abstract_name?): treat an
  empty path as an abstract name.

* test/socket/test_unix.rb: related test.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38994 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-31 04:59:31 +00:00
shugo e16b8482c7 * ext/socket/unixsocket.c (rsock_init_unixsock): use rb_inspect()
because rb_sys_fail_str() fails if its argument contains NUL.

* test/socket/test_unix.rb: related test.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-30 06:30:12 +00:00
shugo a1ed445b81 * ext/socket/socket.c (sock_s_pack_sockaddr_un): calculate the
correct address length of an abstract socket.

* test/socket/test_unix.rb: related test.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38963 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-29 00:32:05 +00:00
shugo ad55d141eb * ext/socket/raddrinfo.c (rsock_unixpath_len, init_unix_addrinfo),
ext/socket/unixsocket.c (unixsock_connect_internal,
  rsock_init_unixsock): calculate the correct address length of
  an abstract socket.  Without this fix, sizeof(struct sockaddr_un)
  is specified as the length of an abstract socket for bind(2) or
  connect(2), so the address of the socket is filled with extra NUL
  characters.  See unix(7) for details.

* ext/socket/lib/socket.rb (unix_server_socket): don't access the
  file system if the platform is Linux and path starts with NUL,
  which means that the socket is an abstract socket.

* test/socket/test_unix.rb: related test.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38939 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-25 08:15:26 +00:00
naruse 643f5308e6 Check if there is no error before reconnect [Bug #4387]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37387 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-30 00:40:54 +00:00
naruse 24793ac32d Revert "Darwin 12 (OS X Mountain Lion) also has Bug #6692"
This reverts commit r37033.
darwin12 seems to use an address started with fe80.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37035 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-26 04:03:26 +00:00
naruse 6fc41b0291 Darwin 12 (OS X Mountain Lion) also has Bug #6692
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37033 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-26 01:26:09 +00:00
naruse 040207ea01 Show nd6 options and whether the packet is reached to the server or not.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36513 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-24 03:09:32 +00:00
naruse 612ff592ff Add version check for darwin's bug.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36511 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-24 00:42:22 +00:00
drbrain f35b1d0633 * test/socket/test_socket.rb: Ignore IPv6 unique local addresses on OS
X (iCloud Back to my Mac addresses) for test_udp_socket since they do
  not act as loopback addresses.  [Bug #6692]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36475 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-20 00:40:48 +00:00
drbrain 3efea48a70 * ext/socket/raddrinfo.c (addrinfo_ipv6_unique_local_p): Added
Addrinfo#ipv6_unique_local? to detect RFC 4193 unique local
  addresses.  Part of #6692
* ext/socket/rubysocket.h:  Add IN6_IS_ADDR_UNIQUE_LOCAL macro if
  missing.
* test/socket/test_addrinfo.rb:  Test for ipv6_unqiue_local?


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36474 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-20 00:32:35 +00:00
naruse 3e972bbaba Check IFDISABLED on Mac OS X.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35645 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-14 07:46:02 +00:00
naruse bfbf9d0956 fix the path of ifconfig.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-10 12:37:56 +00:00
naruse ba8a74314e skip addresses whose interface is set as POINTOPOINT.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35611 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-10 08:29:33 +00:00
naruse 08b3a446e5 Skip IPv6 addresses whose interface is set as IFDISABLED.
FreeBSD 9.0 with default setting (ipv6_activate_all_interfaces
is not YES) sets IFDISABLED to interfaces which don't have
global IPv6 address.
Link-local IPv6 addresses on those interfaces don't work.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-10 03:47:10 +00:00
akr 1413510ed2 * ext/socket/raddrinfo.c (init_unix_addrinfo): support the longest
path in sockaddr_un.
  (inspect_sockaddr): ditto.
  (addrinfo_mdump): ditto.
  (addrinfo_mload): ditto.
  (rsock_unixpath_str): new function.
  (rsock_unixpath): removed.
  (rsock_unixaddr): use rsock_unixpath_str.

* ext/socket/socket.c (sock_s_pack_sockaddr_un): support the longest
  path in sockaddr_un.
  (sock_s_unpack_sockaddr_un): ditto.
  (sock_s_gethostbyaddr): unused variable removed.

* ext/socket/unixsocket.c (rsock_init_unixsock): support the longest
  path in sockaddr_un.

* ext/socket/rubysocket.h (rsock_unixpath_str): declared.
  (rsock_unixpath): removed.

* test/socket/test_unix.rb: comment out test_nul because abstract unix
  sockets may contain NULs.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35474 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-26 03:34:12 +00:00
akr 146aff91c4 * test/socket/test_unix.rb (bound_unix_socket): make temporary
filename shorter for less possibility of Unix socket path over
  107 bytes when TMPDIR has long path.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35436 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-23 13:09:48 +00:00
akr 268d1a2244 * ext/socket/lib/socket.rb (family_addrinfo): return the given
addrinfo object.
  Patch by Ippei Obayashi.  [ruby-dev:45095] [Bug #5845]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34244 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-09 11:11:24 +00:00
naruse 6e9a14aabe Cent OS 5.6 (2.6.18-238.19.1.el5xen) doesn't correctly work
sendmsg with pktinfo for link-local ipv6 addresses

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34232 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-07 23:04:20 +00:00
akr 88f1b8cf0c add test for close-on-exec.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33617 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-03 11:15:15 +00:00
akr df6a0fe8bb close a socket in test_socket_new.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33616 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-03 10:55:26 +00:00
akr 4db0c519f5 * test/socket/test_socket.rb (test_connect_timeout): added a test
based on a patch by Eric Wong.  [ruby-core:38910]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-13 20:58:11 +00:00
akr e504a81ff1 * test/socket/test_unix.rb: don't use Thread.abort_on_exception.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32063 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-13 14:12:23 +00:00