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

49 Коммитов

Автор SHA1 Сообщение Дата
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
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
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 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 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
akr 9778737d7b * ext/socket/unixsocket.c (unix_send_io): race condition fixed.
(unix_recv_io): ditto.
  fixed by Eric Wong.  [ruby-core:35574]

* test/socket/test_unix.rb: test added for above problem.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32062 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-13 14:11:23 +00:00
nobu 603363369b * test/socket/test_unix.rb (TestSocket_UNIXSocket#test_recvmsg):
skip if AncillaryData is not available.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27531 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-04-28 08:54:07 +00:00
akr a967f738c8 * lib/matrix.rb: suppress warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26417 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-01-25 22:08:29 +00:00
nobu 287a34ae0d * {ext,lib,test}/**/*.rb: removed trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-03-06 03:56:38 +00:00
akr fb5d4ecfb5 * ext/socket/ancdata.c (rsock_discard_cmsg_resource): defined
unconditionally.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22710 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-03-02 12:14:35 +00:00
akr d8c66c4333 * ext/socket/ancdata.c (bsock_recvmsg_internal): close FDs passed by
SCM_RIGHTS unless :scm_rights=>true is given.
  (discard_cmsg): extracted from rsock_discard_cmsg_resource.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22667 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-27 14:23:54 +00:00
akr 56c52c1da8 * ext/socket/ancdata.c (ancillary_s_unix_rights): new method.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-25 14:19:24 +00:00
akr bed4294451 * ext/socket/ancdata.c (ancillary_unix_rights): method renamed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22452 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-19 12:13:38 +00:00
akr 18afbc891c * 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
2009-02-18 18:43:15 +00:00
akr 3f0d724dc3 * ext/socket/lib/socket.rb (Socket.unix_server_socket): close the
socket when the block exits.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-11 07:54:52 +00:00
akr 0a954e9117 * ext/socket/lib/socket.rb (Socket.unix_server_socket): call the block
if given.  remove the socket file when the block exits.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22233 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-11 07:51:53 +00:00
akr a8de15e0b5 rename tests classes.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-11 04:17:57 +00:00
akr b4e50055c3 * ext/socket/extconf.rb: check getpeereid.
* ext/socket/basicsocket.c (bsock_getpeereid): new method.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22219 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-11 01:22:08 +00:00
akr fd9c7e8af1 * ext/socket/ancdata.c (ancillary_initialize): add family argument.
(ancdata_new): ditto.
  (ancillary_s_int): ditto.
  (ancillary_family): new function.
  (ancillary_family_m): new method.
  (ancillary_s_ip_pktinfo): follow ancdata_new change.
  (ancillary_s_ipv6_pktinfo): ditto.
  (bsock_recvmsg_internal): examine the socket address family.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-09 10:49:16 +00:00
akr 64f12a46d5 * ext/socket/option.c (inspect_peercred): struct ucred contains
effective uid/gid.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22144 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-08 17:04:40 +00:00
akr 2992642245 LOCAL_PEERCRED is also available on MacOS X.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-08 15:49:35 +00:00
akr f11d2b55f7 * ext/socket/option.c (inspect_local_peercred): cr_uid is a effective
uid, not a real uid.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22138 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-08 15:42:17 +00:00
akr 9e45748143 * ext/socket/extconf.rb: check sys/param.h and sys/ucred.h.
* ext/socket/rubysocket.h: include sys/param.h and sys/ucred.h.

* ext/socket/option.c (inspect_local_peercred): new function to show
  LOCAL_PEERCRED socket option on FreeBSD.
  (sockopt_inspect): show as LOCAL_* socket option if AF_UNIX and level
  is 0.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22137 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-08 15:37:55 +00:00
akr e5f588c83d remove debug print.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22133 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-08 14:39:59 +00:00
akr 8f9d6d1863 * ext/socket/option.c (inspect_peercred): new function to show
SO_PEERCRED socket option.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22131 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-08 14:23:16 +00:00
akr 411e9997d2 * ext/socket/extconf.rb: check struct cmsgcred.
* ext/socket/ancdata.c (anc_inspect_passcred_credentials): add
  "(ucred)".
  (anc_inspect_socket_creds): show struct cmsgcred too, for FreeBSD.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22129 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-08 12:53:55 +00:00
akr eb636217f6 test renamed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22127 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-08 11:37:39 +00:00
akr e960cf417a * ext/socket/extconf.rb: check struct sockcred.
* ext/socket/ancdata.c (anc_inspect_socket_creds): new function to
  show SCM_CREDS on NetBSD.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-08 11:36:18 +00:00
akr 732b695163 add a test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22125 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-08 11:30:26 +00:00
akr 88f04bdd32 * ext/socket: AddrInfo is renamed to Addrinfo. [ruby-dev:37876]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22077 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-05 11:01:43 +00:00
akr 61fc0c6cf4 * ext/socket/rubysocket.h (cmsg_type_arg): declared.
(Init_ancdata): ditto.

* ext/socket/init.c (Init_socket_init): call Init_ancdata.

* ext/socket/constants.c (cmsg_type_arg): defined.

* ext/socket/depend: add dependency for ancdata.o.

* ext/socket/mkconstants.rb: generate scm_optname_to_int.
  more constants.

* ext/socket/extconf.rb: add ancdata.o.

* ext/socket/ancdata.c: new file.  new method
  BasicSocket#{sendmsg,sendmsg_nonblock,recvmsg,recvmsg_nonblock}



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21943 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-02 02:51:02 +00:00
akr 0cd078e358 don't get a name for anonymous Unix socket.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-05 13:40:42 +00:00
akr 0c838b4947 * ext/socket/mkconstants.rb: generate family_to_int().
* ext/socket/socket.c (setup_domain_and_type): use family_to_int.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21240 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-01 07:49:31 +00:00
akr ddedc6f125 * ext/socket/socket.c (sock_s_socketpair): yield if a block is given.
(io_call_close): defined.
  (io_close): defined.
  (pair_yield): defined.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21216 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-31 15:05:16 +00:00
akr 895c7cb3c4 add an assertion.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17746 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-30 14:05:20 +00:00
akr cac79cc388 add a test for [ruby-dev:34619].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17742 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-30 13:50:13 +00:00
akr 228728325e UNIXServer.new("a\0b") test removed because
UNIXServer.new accepts NUL as abstruct unix sockets.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13552 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-28 15:58:34 +00:00
akr fd7f570cb2 * test/socket/test_unix.rb: disabled on cygwin.
reported by Kouhei Yanagita.  [ruby-dev:29080]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10585 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-07-23 14:03:28 +00:00
akr 91ea1529c6 * test/socket/test_unix.rb: test_seqpacket_pair removed.
[ruby-dev:28846]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10421 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-28 10:07:52 +00:00
akr b73e6801e3 * ext/socket/socket.c (bsock_recv_nonblock): new method
BasicSocket#recv_nonblock.
  (udp_recvfrom_nonblock): renamed from ip_recvfrom_nonblock.
  IPSocket#recvfrom_nonblock is moved to UDPSocket#recvfrom_nonblock.
  (unix_recvfrom_nonblock): removed.
  UNIXSocket#recvfrom_nonblock is removed.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10403 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-26 16:39:59 +00:00
akr a0261afccd getsockname returns "" on MacOS X
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10230 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-07 10:57:26 +00:00
akr 9fcf44697a fix tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10216 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-04 12:15:01 +00:00
akr d3fde50de7 * ext/socket/socket.c: fix sockaddr_un handling.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-04 11:45:09 +00:00
akr ddbe529c62 * ext/socket/socket.c (unix_send_io, unix_recv_io): support x86-64 and
IA64.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8702 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-07-02 13:45:08 +00:00
akr f27ff52d1e add a test for file descriptor passing.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-06-04 02:40:40 +00:00