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

755 Коммитов

Автор SHA1 Сообщение Дата
nobu 7e4a95cd06 socket.c: suppress warnings
* ext/socket/socket.c (rsock_sys_fail_sockaddr): cast down explicitly
  to suppress warnings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-06 07:58:47 +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 b1fd376cbf * ext/socket/socket.c (rsock_sys_fail_sockaddr): Delete 2nd argument.
* ext/socket/rubysocket.h (rsock_sys_fail_sockaddr): Follow above
  change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40153 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-06 04:35:29 +00:00
akr 8c6c73745e * ext/socket/socket.c (rsock_sys_fail_path): Use rb_str_inspect only
for String to avoid SEGV.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40152 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-06 04:14:57 +00:00
akr 24ee6971cc * ext/socket/rubysocket.h (rsock_sys_fail_host_port) Wrap by NORETURN.
(rsock_sys_fail_path): Ditto.
  (rsock_sys_fail_sockaddr): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40151 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-06 03:41:01 +00:00
akr 11a9d77286 * ext/socket/socket.c (rsock_sys_fail_path): Use rb_str_inspect if the
path contains a NUL.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40150 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-06 02:50:08 +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
akr fbb29bc08c * ext/socket/init.c (cloexec_accept): Fix a compile error on
Debian GNU/kFreeBSD.  Consider HAVE_ACCEPT4 is defined
  but SOCK_CLOEXEC is not defined.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40136 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-05 16:40:36 +00:00
akr b2a1339f24 * ext/socket/extconf.rb: Remove condition for bcc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40111 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-04 14:25:19 +00:00
akr da39199964 * ext/socket/extconf.rb: Specify arguments to test functions.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40092 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-03 22:24:57 +00:00
akr 7181490def * ext/socket/extconf.rb: Test functions and libraries after headers.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40086 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-03 13:10:04 +00:00
akr 7371736e49 * ext/socket/socket.c (sockaddr_len): return the shortest length for
unknown socket address.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39941 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-26 14:34:20 +00:00
nobu a7e5f0b5ee internal.h: export rb_sys_fail_path_with_func
* internal.h (rb_sys_fail_path_with_func): export for
  socket/basicsocket.c.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-15 06:08:13 +00:00
akr ca4397ad2c update doc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39750 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-14 03:49:30 +00:00
zzak 2a5b45ddc5 * ext/socket/tcpserver.c: Grammar for TCPServer.new from r39554
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39571 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-02 22:34:29 +00:00
akr fa0630558f update doc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39554 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-02 15:01:44 +00:00
akr 338ec3cee7 * ext/socket/raddrinfo.c (inspect_sockaddr): don't show that Unix
domain socket filename is bigger than sizeof(sun_path).
  This limit is not rigid on some platforms such as Darwin and SunOS.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39538 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-28 13:29:55 +00:00
akr bf96ea6362 * ext/socket/rubysocket.h (union_sockaddr): make it longer for SunOS
and Darwin.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39529 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-27 13:55:19 +00:00
akr 1580dd29dd * ext/socket/extconf.rb: don't test ss_family and ss_len member of
struct sockaddr_storage.  They are not used now except SunOS
  specific code.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39483 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-25 03:40:16 +00:00
akr c89844dbc5 * ext/socket: define and use union_sockaddr instead of struct
sockaddr_storage for less casts.

* ext/socket/rubysocket.h (union_sockaddr): defined.

* ext/socket/socket.c (sock_accept): use union_sockaddr.
  (sock_accept_nonblock): ditto.
  (sock_sysaccept): ditto.
  (sock_s_getnameinfo): ditto.

* ext/socket/basicsocket.c (bsock_getsockname): ditto.
  (bsock_getpeername): ditto.
  (bsock_local_address): ditto.
  (bsock_remote_address): ditto.

* ext/socket/ancdata.c (bsock_recvmsg_internal): ditto.

* ext/socket/init.c (recvfrom_arg): ditto.
  (recvfrom_blocking): ditto.
  (rsock_s_recvfrom): ditto.
  (rsock_s_recvfrom_nonblock): ditto.
  (rsock_getfamily): ditto.

* ext/socket/raddrinfo.c (rb_addrinfo_t): ditto.
  (ai_get_afamily): ditto.
  (inspect_sockaddr): ditto.
  (addrinfo_mdump): ditto.
  (addrinfo_mload): ditto.
  (addrinfo_getnameinfo): ditto.
  (addrinfo_ip_port): ditto.
  (extract_in_addr): ditto.
  (addrinfo_ipv6_to_ipv4): ditto.
  (addrinfo_unix_path): ditto.

* ext/socket/tcpserver.c (tcp_accept): ditto.
  (tcp_accept_nonblock): ditto.
  (tcp_sysaccept): ditto.

* ext/socket/ipsocket.c (ip_addr): ditto.
  (ip_peeraddr): ditto.
  (ip_s_getaddress): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39477 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-24 17:51:17 +00:00
akr 75a5be3717 * ext/socket/ancdata.c (rsock_recvmsg): ignore truncated part of
socket address returned from recvmsg().

* ext/socket/init.c (recvfrom_blocking): ignore truncated part of
  socket address returned from recvfrom().
  (rsock_s_recvfrom_nonblock): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-16 11:44:42 +00:00
akr 733d65df5e * ext/socket/extconf.rb: don't test sys/feature_tests.h which is not
used now.
  It was included in r7901 as "bug of gcc 3.0 on Solaris 8 ?".



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39265 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-16 00:59:24 +00:00
akr 4b5b88ec79 * ext/socket/extconf.rb: reorder header tests to consider inclusion
order in rubysocket.h.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39264 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-16 00:25:54 +00:00
akr d6d0e85320 * configure.in, ext/socket/extconf.rb: test netinet/in_systm.h in
ext/socket/extconf.rb instead of configure.in.

  Originally, netinet/in_systm.h is included for NextStep, OpenStep,
  and Rhapsody.  [ruby-core:1596]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39263 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-15 23:46:44 +00:00
akr 899ba99b90 * configure.in: don't test xti.h here.
* ext/socket/extconf.rb: test xti.h here.

  Originally, xti.h is included for IRIX [ruby-core:14447].



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39262 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-15 22:59:40 +00:00
akr 35f8072e5c preprocessor directives indented.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-15 22:53:59 +00:00
akr cb31e78379 * ext/socket/extconf.rb: test struct sockaddr_un and its member,
sun_len.

* ext/socket/sockport.h (INIT_SOCKADDR_UN): new macro defined.

* ext/socket/socket.c (sock_s_pack_sockaddr_un): use INIT_SOCKADDR_UN.

* ext/socket/unixsocket.c (rsock_init_unixsock): ditto.

* ext/socket/raddrinfo.c (init_unix_addrinfo): ditto.
  (addrinfo_mload): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39260 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-15 22:19:05 +00:00
akr 84a525bc4e * ext/socket/sockport.h (INIT_SOCKADDR_IN): don't need family
argument.  it is always AF_INET.

* ext/socket/raddrinfo.c (make_inetaddr): follow INIT_SOCKADDR_IN
  change.
  (addrinfo_ipv6_to_ipv4): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-15 22:08:25 +00:00
usa cd63b84ce9 * ext/socket/extconf.rb: workaround for mswin/mingw build problem.
sendmsg emulation in win32/win32.c is not enough.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39258 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-15 19:23:50 +00:00
akr 41b2a6f01b * ext/socket/extconf.rb: use all all tested available headers for
have_func.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-15 15:20:34 +00:00
akr e41b789c99 * ext/socket/sockport.h (SET_SIN_LEN): defined for strict-aliasing
rule.
  (INIT_SOCKADDR_IN): ditto.

* ext/socket/raddrinfo.c (make_inetaddr): use INIT_SOCKADDR_IN.
  (addrinfo_ipv6_to_ipv4): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39254 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-15 11:30:19 +00:00
nobu 66c1e7960c socket: ai_addrlen is socklen_t
* ext/socket/raddrinfo.c (rsock_make_hostent): ai_addrlen is not
  size_t but socklen_t.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39251 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-15 07:54:38 +00:00
akr a60e2e5820 * ext/socket/extconf.rb: test struct sockaddr_storage directly.
* ext/socket/rubysocket.h: use HAVE_TYPE_STRUCT_SOCKADDR_STORAGE.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39250 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-15 03:36:05 +00:00
akr 0cc9cea3b4 * ext/socket/getaddrinfo.c (GET_AI): don't cast 1st argument for
INIT_SOCKADDR.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39249 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-15 03:27:05 +00:00
akr 1ff7108306 * ext/socket/sockport.h (SET_SS_LEN): removed.
(SET_SIN_LEN): removed.
  (INIT_SOCKADDR): new macro.

* ext/socket/ancdata.c (extract_ipv6_pktinfo): use INIT_SOCKADDR.

* ext/socket/raddrinfo.c (make_inetaddr): use INIT_SOCKADDR.
  (addrinfo_ipv6_to_ipv4): ditto.

* ext/socket/getaddrinfo.c (GET_AI): use INIT_SOCKADDR.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39248 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-14 23:14:22 +00:00
akr 4faef960f2 * ext/socket/sockport.h (SA_LEN): removed because unused now.
(SS_LEN): ditto.
  (SIN_LEN): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39246 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-14 22:08:28 +00:00
akr 792cfa3fd0 * ext/socket/sockport.h (VALIDATE_SOCKLEN): new macro to validate
sa_len member of 4.4BSD socket address.

* ext/socket/getnameinfo.c (getnameinfo): use VALIDATE_SOCKLEN,
  instead of SA_LEN.

* ext/socket/socket.c (sock_s_getnameinfo): use VALIDATE_SOCKLEN
  instead of SS_LEN. 



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39242 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-14 15:17:49 +00:00
akr 1cc445fbbf * ext/socket/socket.c (sockaddr_len): extracted from sockaddr_obj.
(sockaddr_obj): add an argument to length of socket address.
  (socket_s_ip_address_list): call sockaddr_obj with actual socket
  address length if given, use sockaddr_len otherwise.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39240 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-14 13:27:46 +00:00
akr 18a8046d1c * ext/socket: always operate length of socket addess companion with
socket address. 

* ext/socket/rubysocket.h (rsock_make_ipaddr): add an argument for
  socket address length.
  (rsock_ipaddr): ditto.

* ext/socket/ipsocket.c (ip_addr): pass length to rsock_ipaddr.
  (ip_peeraddr): ditto.
  (ip_s_getaddress): pass length to rsock_make_ipaddr.

* ext/socket/socket.c (make_addrinfo): pass length to rsock_ipaddr.
  (sock_s_getnameinfo): pass actual address length to rb_getnameinfo.
  (sock_s_unpack_sockaddr_in): pass length to rsock_make_ipaddr.
  
* ext/socket/init.c (rsock_s_recvfrom): pass length to rsock_ipaddr.
  (rsock_s_recvfrom_nonblock): ditto.

* ext/socket/tcpsocket.c (tcp_sockaddr): pass length to
  rsock_make_ipaddr.

* ext/socket/raddrinfo.c (make_ipaddr0): add an argument for socket
  address length.  pass the length to rb_getnameinfo.
  (rsock_ipaddr): ditto.
  (rsock_make_ipaddr): add an argument for socket address length. 
  pass the length to make_ipaddr0.
  (make_inetaddr): pass length to make_ipaddr0.
  a local variable renamed.
  (host_str): a local variable renamed.
  (port_str): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-14 11:28:49 +00:00
akr ed193c50f5 * ext/socket/extconf.rb: don't define HAVE_SA_LEN and HAVE_SA_LEN.
use HAVE_STRUCT_SOCKADDR_SA_LEN and HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
  instead.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39230 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-13 23:20:27 +00:00
akr eb4ae6bc54 add comment.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39226 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-13 14:41:28 +00:00
akr 22a04e5720 * ext/socket/extconf.rb: don't define socklen_t here, just test.
* ext/socket/rubysocket.h: define socklen_t if not available.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-13 12:01:24 +00:00
akr d7923c8279 * ext/socket/extconf.rb: test functions just after struct members.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39211 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-12 20:51:19 +00:00
akr c799b11273 * ext/socket/extconf.rb: test structure members just after types test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-10 14:43:00 +00:00
akr 5b057eeff2 * ext/socket/extconf.rb: test types just after headers test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39196 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-10 11:58:53 +00:00
akr 474e3cd2a7 add comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39183 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-10 03:29:37 +00:00
akr 1ab6dccf4b * ext/socket/extconf.rb: test headers at first.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39182 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-10 03:11:00 +00:00
nobu a9cbe8c721 init.c: declaration-after-statement
* ext/socket/init.c (cloexec_accept): fix declaration-after-statement.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39040 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-04 06:19:40 +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
akr 1ff38a5bbf * ext/socket/basicsocket.c (bsock_getsockname): ignore truncated
part of socket address.
  (bsock_getpeername): ditto.
  (bsock_local_address): ditto.
  (bsock_remote_address): ditto.

* ext/socket/unixsocket.c (unix_path): ditto.
  (unix_addr): ditto.
  (unix_peeraddr): ditto.

* ext/socket/init.c (cloexec_accept): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38993 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-30 12:01:51 +00:00