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

148 Коммитов

Автор SHA1 Сообщение Дата
Samuel Williams 844a9dff88
Try `nil` as default for 'default timeout'. (#6509) 2022-10-08 14:02:34 +13:00
Samuel Williams e4f91bbdba
Add IO#timeout attribute and use it for blocking IO operations. (#5653) 2022-10-07 21:48:38 +13:00
Takashi Kokubun 5b21e94beb Expand tabs [ci skip]
[Misc #18891]
2022-07-21 09:42:04 -07:00
Nobuyoshi Nakada e057b9eea9
Prefer the reentrant versions of gmtime and localtime 2021-10-14 23:44:15 +09:00
Samuel Williams 45e65f302b Deprecate and rework old (fd) centric functions. 2021-06-22 22:48:57 +12:00
Aaron Patterson 9f3adaf529 Use public allocators for creating new T_OBJECT objects
This way the header flags and object internals are set correctly
2020-10-28 18:35:22 -07:00
Samuel Williams 0e3b0fcdba
Thread scheduler for light weight concurrency. 2020-05-14 22:10:55 +12:00
Jeremy Evans ffd0820ab3 Deprecate taint/trust and related methods, and make the methods no-ops
This removes the related tests, and puts the related specs behind
version guards.  This affects all code in lib, including some
libraries that may want to support older versions of Ruby.
2019-11-18 01:00:25 +02:00
Tanaka Akira 4900a10689 socket: use frozen string buffer when releasing GVL
Thanks for the patch by normalperson (Eric Wong) [Bug #14204].
2019-07-14 20:46:51 +09:00
hsbt 4043565023 * ext/socket/*.c: Add proper require for example to work.
[fix GH-1378][ci skip] Patch by @schneems

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-05 03:57:32 +00:00
nobu f9adadc5e6 rb_readwrite_syserr_fail
* io.c (rb_readwrite_syserr_fail): works with the given errno than
  thread local errno.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53265 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-23 14:58:47 +00:00
nobu f4166e2dd7 prefer rb_syserr_fail
* file.c, io.c, util.c: prefer rb_syserr_fail with saved errno
  over setting errno then call rb_sys_fail, not to be clobbered
  potentially and to reduce thread local errno accesses.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53264 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-23 08:57:48 +00:00
akr 33b832979b * ext/socket/ancdata.c: Check buffer full and ignore MSG_TRUNC flag.
buffer fullness is more robust to detect the message is too big for
  the buffer.
  AIX 7.1 recvmsg doesn't set MSG_TRUNC for rflags when MSG_PEEK is
  given.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52673 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-19 13:49:58 +00:00
usa 3006e5ea78 * ext/socket/ancdata.c (bsock_recvmsg_internal): stretch the buffer size
only when vmaxdatlen is nil.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-18 17:53:20 +00:00
usa d8e1939232 * ext/socket/ancdata.c (bsock_recvmsg_internal): stretch the buffer size
when EMSGSIZE occurs on non HAVE_STRUCT_MSGHDR_MSG_CONTROL platforms
  (such as, Windows).  fixes a test error revealed by r52625.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-18 01:37:34 +00:00
normal ca5f5871e8 socket: fix typo for default size
* ext/socket/ancdata.c (bsock_recvmsg_internal): use 4096 as
  default size to match pre-r52610, which also maps to a common
  page size.

Oops; absolutely no idea why I made this typo...

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-18 01:18:30 +00:00
normal 508b5fdd52 socket: fix recvmsg without argument
* ext/socket/ancdata.c (bsock_recvmsg_internal): grow buffer
  on unspecified maxdatlen
  [ruby-core:71517] [Bug #11701]
* ext/socket/lib/socket.rb (Socket#recvmsg): nil default for dlen
  (Socket#recvmsg_nonblock): ditto
* test/socket/test_socket.rb (test_recvmsg_udp_no_arg): new test

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52625 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-17 22:00:23 +00:00
usa 66e2139b1a * ext/socket/lib/socket.rb (Socket#recvmsg{,_nonblock}): default values
of clen must be nil.

* ext/socket/ancdata.c (bsock_sendmsg_internal): handle nil of clen.
  fixes test errors introduced at r52602.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-17 05:06:18 +00:00
normal eda2441b53 socket: avoid arg parsing in bsock_sendmsg_internal
* ext/socket/ancdata.c (bsock_sendmsg_internal): avoid arg parsing
  [ruby-core:71439] [Feature #11339]
  (rsock_bsock_sendmsg): make private, adjust for above
  (rsock_bsock_sendmsg_nonblock): ditto
* ext/socket/rubysocket.h: adjust prototypes
  (rsock_opt_false_p): remove
* ext/socket/basicsocket.c (rsock_init_basicsocket):
  define private methods
* ext/socket/lib/socket.rb (BasicSocket#sendmsg): new wrapper
  (BasicSocket#sendmsg_nonblock): ditto

target 0: a (ruby 2.3.0dev (2015-11-12 trunk 52550) [x86_64-linux])
target 1: b (ruby 2.3.0dev (2015-11-12 avoid-kwarg-capi 52550) [x86_64-linux]

-----------------------------------------------------------
sendmsg_nonblock

require 'socket'
nr = 1_000_000
i = 0
msg = '.'
buf = '.'
begin
  r, w = UNIXSocket.pair(:SEQPACKET)
  while i < nr
    i += 1
    w.sendmsg_nonblock(msg, exception: false)
    r.recv(1, 0, buf)
  end
ensure
  r.close
  w.close
end

-----------------------------------------------------------
raw data:

[["sendmsg_nonblock",
  [[1.875997293740511,
    1.8452614955604076,
    1.8449317328631878,
    1.8418389447033405,
    1.869386937469244],
   [1.5175109766423702,
    1.4987873211503029,
    1.4989623799920082,
    1.47918451577425,
    1.5017359890043736]]]]

Elapsed time: 16.775453245 (sec)
-----------------------------------------------------------
benchmark results:
minimum results in each 5 measurements.
Execution time (sec)
name             a       b
sendmsg_nonblock   1.842   1.479

Speedup ratio: compare with the result of `a' (greater is better)
name             b
sendmsg_nonblock   1.245

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-17 01:05:30 +00:00
normal 416c50f574 socket (bsock_recvmsg_internal): avoid arg parsing
* ext/socket/ancdata.c (bsock_recvmsg_internal): avoid arg parsing
  (rsock_bsock_recvmsg): adjust for above change
  (rsock_bsock_recvmsg_nonblock): ditto
  [ruby-core:71439] [Feature #11339]
* ext/socket/rubysocket.h: adjust prototypes for above
* ext/socket/basicsocket.c (rsock_init_basicsocket):
  adjust private methods
* ext/socket/lib/socket.rb (BasicSocket#recvmsg): wrapper method
  (BasicSocket#recvmsg_nonblock): ditto

target 0: a (ruby 2.3.0dev (2015-11-12 trunk 52550) [x86_64-linux])
target 1: b (ruby 2.3.0dev (2015-11-12 avoid-kwarg-capi 52550) [x86_64-linux]

-----------------------------------------------------------
recvmsg_nonblock

require 'socket'
nr = 1_000_000
i = 0
msg = '.'
buf = '.'
begin
  r, w = UNIXSocket.pair(:SEQPACKET)
  while i < nr
    i += 1
    w.sendmsg(msg)
    r.recvmsg_nonblock(1, exception: false)
  end
ensure
  r.close
  w.close
end

-----------------------------------------------------------
raw data:

[["recvmsg_nonblock",
  [[3.721687912940979,
    3.6072621569037437,
    3.580637402832508,
    3.614185404032469,
    3.6029579415917397],
   [2.4694008752703667,
    2.4908322244882584,
    2.5051278844475746,
    2.5037173740565777,
    2.548359278589487]]]]

Elapsed time: 30.646087052 (sec)
-----------------------------------------------------------
benchmark results:
minimum results in each 5 measurements.
Execution time (sec)
name             a       b
recvmsg_nonblock   3.581   2.469

Speedup ratio: compare with the result of `a' (greater is better)
name             b
recvmsg_nonblock   1.450

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52602 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-17 00:58:23 +00:00
nobu 57e2877e7b ext: use RARRAY_AREF
* ext/**/*.c: prefer RARRAY_AREF to indexing RARRAY_CONST_PTR.
  pointed out by hanmac.
  https://github.com/ruby/ruby/commit/3553a86#commitcomment-14187670

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52453 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-05 01:09:17 +00:00
nobu 3553a86eb5 ext: use RARRAY_CONST_PTR
* ext/bigdecimal/bigdecimal.c: use RARRAY_CONST_PTR just fore
  reference instead of RARRAY_PTR, to keep the array WB-protected.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52448 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-04 07:27:10 +00:00
nobu b5a5cd605b use rb_sym2str
* ext/openssl/ossl_ssl.c (ossl_sslctx_set_ssl_version): use
  rb_sym2str to get rid of inadvertent ID creations.

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

* ext/socket/option.c (sockopt_inspect): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-15 04:32:15 +00:00
normal 6dda4f17a9 socket: memoize common socket families in fptr->mode
This provides a minor speedup by avoiding an extra syscall

	require 'socket'
	require 'benchmark'
	nr = 100000
	msg = 'hello world'
	buf = ''
	size = msg.bytesize
	puts(Benchmark.measure do
	  UNIXSocket.pair(:SEQPACKET) do |a, b|
	    nr.times do
	      a.sendmsg_nonblock(msg, 0, exception: false)
	      b.recv(size, 0, buf)
	    end
	  end
	end)

             user     system      total        real
before:  0.330000   0.340000   0.670000 (  0.678235)
 after:  0.290000   0.240000   0.530000 (  0.534527)

* ext/socket/rubysocket.h: flags for common socket families
  (rsock_getfamily): update signature
* include/ruby/io.h: comment socket FMODE flags
* ext/socket/init.c (rsock_getfamily): memoize family
* ext/socket/basicsocket.c: adjust rsock_getfamily calls
* ext/socket/ancdata.c: ditto
  [ruby-core:69713] [Feature #11298]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-02 01:58:14 +00:00
normal d9d1b20d39 ext/socket/ancdata.c (bsock_recvmsg_internal): reduce stack use
Using 8K stack is probably too much.  As reference, ALLOCV falls
back to heap allocation at a mere 1K.  Since
bsock_recvmsg_internal is a function which will always allocate
and can trigger GC, it is in our best interest to minimize
stack usage to avoid scanning 8K of stack on GC.

[ruby-core:69595] [Feature #11263]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51003 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-23 23:40:53 +00:00
normal b9a91334c5 socket: allow exception-free nonblocking sendmsg/recvmsg
As documented before, exceptions are expensive and IO::Wait*able are too
common in socket applications to be the exceptional case.  Datagram
sockets deserve the same API which stream sockets are allowed with
read_nonblock and write_nonblock.

Note: this does not offer a performance advantage under optimal
conditions when both ends are equally matched in speed, but it it
does make debug output cleaner by avoiding exceptions whenever
the receiver slows down.

* ext/socket/ancdata.c (bsock_sendmsg_internal, bsock_recvmsg_internal):
  support "exception: false" kwarg
* ext/socket/init.c (rsock_s_recvfrom_nonblock):
  ditto
* ext/socket/init.c (rsock_s_recvfrom_nonblock): use rsock_opt_false_p
* ext/socket/socket.c (sock_connect_nonblock): ditto
* ext/socket/rubysocket.h (rsock_opt_false_p): new function
* ext/socket/basicsocket.c (bsock_recv_nonblock): update rdoc
* ext/socket/udpsocket.c (udp_recvfrom_nonblock): ditto
* test/socket/test_nonblock.rb: new tests

[ruby-core:69542] [Feature #11229]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50910 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-15 19:38:49 +00:00
normal 5a67d8e2e9 * ext/socket/ancdata.c (bsock_sendmsg_internal): drop redundant assignment
We call memset to zero `mh' a few lines above anyways, making
explicitly zero-ing each field unnecessary.

Compilers optimize this code away anyways, but it still costs me
4 lines of my small terminal and even smaller attention span.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50786 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-05 22:21:47 +00:00
ngoto 607abcc7be * ext/socket/ancdata.c (bsock_sendmsg_internal): all arguments are
parsed even on systems without HAVE_STRUCT_MSGHDR_MSG_CONTROL
  to prevent SEGV caused by passing Qnil to RARRAY_LENINT and
  to preserve behavior before r50776.
  [Bug #11224] [ruby-core:69468] [Bug #11225] [ruby-core:69469]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-05 16:11:47 +00:00
normal 7ac8fe7407 ext/socket/ancdata.c (bsock_sendmsg_internal): portability fix
* ext/socket/ancdata.c (bsock_sendmsg_internal): avoid msg_control
  ptr if msg_controllen is zero to fix portability problems.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-05 08:28:14 +00:00
normal 20dedbfd9d ext/socket/ancdata.c (bsock_sendmsg_internal): fix build error from r50776
Systems without HAVE_STRUCT_MSGHDR_MSG_CONTROL still need
controls to be nil for the check after argument parsing.

Note: not actually tested on a real system without msg_control

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50780 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-05 00:18:30 +00:00
normal c467547301 ext/socket/ancdata.c (bsock_sendmsg_internal): use rb_scan_args
This should make the code more maintainable and make it easier to
add keyword argument support for "exception: false" in the future.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50776 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-04 20:50:08 +00:00
normal 5e3455597d ext/socket/ancdata.c: use RB_GC_GUARD instead of volatile
See doc/extension.rdoc for explanation.

[ruby-core:69419] [Feature #11198]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-30 08:19:37 +00:00
normal d8bbb5eda8 socket: avoid redundant fcntl on Linux
* ext/socket/ancdata.c (bsock_sendmsg_internal,
  bsock_recvmsg_internal):
  avoid redundant fcntl on Linux
  [ruby-core:69154] [Feature #11145]
* ext/socket/init.c (rsock_s_recvfrom_nonblock): ditto
* ext/socket/rubysocket.h (MSG_DONTWAIT_RELIABLE): new macro

MSG_DONTWAIT is enough to force non-blocking I/O under Linux,
so avoid changing the state of a socket.  This will allow certain
threads to do a non-destructive non-blocking "peek" while others
block (without relying on an extra ppoll syscall).

We shall be conservative about enabling this feature since some
OSes may have incomplete support for MSG_DONTWAIT.  I shall
defer to a FreeBSD expert to enable that for FreeBSD.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50666 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-29 02:24:18 +00:00
normal c3d826bb2b ext/socket/ancdata.c (bsock_recvmsg_internal): GC guard
The control buffer may be used throughout the function, so
prevent the string from being lost to GC.

* ext/socket/ancdata.c (bsock_recvmsg_internal): GC guard
  [Bug #11123]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50449 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-08 22:31:02 +00:00
normal 4d10c2b91d ext/socket/*.c: trivial struct packing for 64-bit
* ext/socket/ancdata.c ({send,recv}msg_args_struct): 24 => 16 bytes
* ext/socket/init.c (connect_arg): ditto
* ext/socket/raddrinfo.c (getnameinfo_arg): 56 => 48 bytes

Other big stack reductions are less trivial.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47679 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-22 00:46:25 +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
akr 965b947fff * ext/socket: Avoid redundant fcntl/fstat syscalls for cloexec
sockets.
  Patch by Eric Wong.  [ruby-core:59429] [Feature #9330]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44728 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-28 14:37:34 +00:00
akr 888e5cbbe7 * process.c: Remove spaces between SI prefix and unit to follow
SI brochure.
  http://www.bipm.org/en/si/si_brochure/
  https://www.nmij.jp/library/units/si/

* time.c: Ditto.

* ext/socket/ancdata.c: Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-09 12:33:36 +00:00
shugo 1f828497d1 * safe.c (rb_set_safe_level, safe_setter): raise an ArgumentError
when $SAFE is set to 4.  $SAFE=4 is now obsolete.
  [ruby-core:55222] [Feature #8468]

* object.c (rb_obj_untrusted, rb_obj_untrust, rb_obj_trust):
  Kernel#untrusted?, untrust, and trust are now deprecated.
  Their behavior is same as tainted?, taint, and untaint,
  respectively.

* include/ruby/ruby.h (OBJ_UNTRUSTED, OBJ_UNTRUST): OBJ_UNTRUSTED()
  and OBJ_UNTRUST() are aliases of OBJ_TAINTED() and OBJ_TAINT(),
  respectively.

* array.c, class.c, debug.c, dir.c, encoding.c, error.c, eval.c,
  ext/curses/curses.c, ext/dbm/dbm.c, ext/dl/cfunc.c,
  ext/dl/cptr.c, ext/dl/dl.c, ext/etc/etc.c, ext/fiddle/fiddle.c,
  ext/fiddle/pointer.c, ext/gdbm/gdbm.c, ext/readline/readline.c,
  ext/sdbm/init.c, ext/socket/ancdata.c, ext/socket/basicsocket.c,
  ext/socket/socket.c, ext/socket/udpsocket.c,
  ext/stringio/stringio.c, ext/syslog/syslog.c, ext/tk/tcltklib.c,
  ext/win32ole/win32ole.c, file.c, gc.c, hash.c, io.c, iseq.c,
  load.c, marshal.c, object.c, proc.c, process.c, random.c, re.c,
  safe.c, string.c, thread.c, transcode.c, variable.c,
  vm_insnhelper.c, vm_method.c, vm_trace.c: remove code for
  $SAFE=4.

* test/dl/test_dl2.rb, test/erb/test_erb.rb,
  test/readline/test_readline.rb,
  test/readline/test_readline_history.rb, test/ruby/test_alias.rb,
  test/ruby/test_array.rb, test/ruby/test_dir.rb,
  test/ruby/test_encoding.rb, test/ruby/test_env.rb,
  test/ruby/test_eval.rb, test/ruby/test_exception.rb,
  test/ruby/test_file_exhaustive.rb, test/ruby/test_hash.rb,
  test/ruby/test_io.rb, test/ruby/test_method.rb,
  test/ruby/test_module.rb, test/ruby/test_object.rb,
  test/ruby/test_pack.rb, test/ruby/test_rand.rb,
  test/ruby/test_regexp.rb, test/ruby/test_settracefunc.rb,
  test/ruby/test_struct.rb, test/ruby/test_thread.rb,
  test/ruby/test_time.rb: remove tests for $SAFE=4.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-12 14:20:51 +00:00
ko1 83aba04862 * include/ruby/ruby.h: constify RBasic::klass and add
RBASIC_CLASS(obj) macro which returns a class of `obj'.
  This change is a part of RGENGC branch [ruby-trunk - Feature #8339].
* object.c: add new function rb_obj_reveal().
  This function reveal interal (hidden) object by rb_obj_hide().
  Note that do not change class before and after hiding.
  Only permitted example is:
  klass = RBASIC_CLASS(obj);
  rb_obj_hide(obj);
  ....
  rb_obj_reveal(obj, klass);
  TODO: API design. rb_obj_reveal() should be replaced with others.
  TODO: modify constified variables using cast may be harmful for
  compiler's analysis and optimizaton.
  Any idea to prohibt inserting RBasic::klass directly?
  If rename RBasic::klass and force to use RBASIC_CLASS(obj),
  then all codes such as `RBASIC(obj)->klass' will be
  compilation error. Is it acceptable? (We have similar
  experience at Ruby 1.9,
  for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)".
* internal.h: add some macros.
* RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal
  object.
* RBASIC_SET_CLASS(obj, cls) set RBasic::klass.
* RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS
  without write barrier (planned).
* RCLASS_SET_SUPER(a, b) set super class of a.
* array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c,
  file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c,
  parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c,
  string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c:
  Use above macros and functions to access RBasic::klass.
* ext/coverage/coverage.c, ext/readline/readline.c,
  ext/socket/ancdata.c, ext/socket/init.c,
* ext/zlib/zlib.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 10:49:11 +00:00
akr 2ffbe0345d * ext/socket/ancdata.c (bsock_sendmsg_internal): controls_num should
not be negative.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40626 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-09 13:01:08 +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
akr a5e6d48dfb * ext/socket/rubysocket.h, ext/socket/unixsocket.c,
ext/socket/ancdata.c: Use HAVE_STRUCT_MSGHDR_MSG_CONTROL instead
  of HAVE_ST_MSG_CONTROL.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40623 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-09 03:08:58 +00:00
akr 593c24f87c * ext/socket/ancdata.c (bsock_recvmsg_internal): Add a cast to
suppress warning.
  Bionic defines socklen_t as int.
  Bionic defines msg_controllen as unsigned int (__kernel_size_t)
  instead of socklen_t as POSIX.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40599 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-07 03:19:52 +00:00
akr cb2f3c1b87 * ext/socket/ancdata.c (ancillary_inspect): Don't call
anc_inspect_ipv6_pktinfo if !HAVE_TYPE_STRUCT_IN6_PKTINFO.
  anc_inspect_ipv6_pktinfo is not defined in the case.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40598 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-07 03:14:47 +00:00
nobu 84c8319c8d ancdata.c: suppress warnings
* ext/socket/ancdata.c (bsock_sendmsg_internal): suppress warnings on
  platforms where msghdr does not have msg_control.

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

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40536 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-01 04:43:00 +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
nobu c7135ddd2d socket/extconf.rb: RSTRING_SOCKLEN
* ext/socket/extconf.rb (RSTRING_SOCKLEN): macro to cast RSTRING_LEN
  to socklen_t.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-06 07:58:51 +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