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

5873 Коммитов

Автор SHA1 Сообщение Дата
nobu ac9d6b050b digest.c: GC guard
* ext/digest/digest.c (hexencode_str_new, rb_digest_base_update):
  prevent argument strings from GC.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50580 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-21 05:03:55 +00:00
nobu 0a933cf3d4 nonblock.c: just yield if the flag is not changed
* ext/io/nonblock/nonblock.c (io_nonblock_set): return whether
  nonblock flag was changed.

* ext/io/nonblock/nonblock.c (rb_io_nonblock_block): nothing to
  restore but just yield unless nonblock flag is changed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50531 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-18 10:30:36 +00:00
nobu 47349e8701 notimplement: rename
* ext/-test-/notimplement, test/-ext-/test_notimplement.rb:
  rename from bug-3662.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50524 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-17 14:47:36 +00:00
normal 8ff35b816a ext/socket/init.c: use SOCK_NONBLOCK if available
This saves a system call by allowing us to use SOCK_NONBLOCK in
Linux when accept4 is available.

Note: I do not agree accept_nonblock should always make accepted
sockets non-blocking, and will propose a future API to allow
controlling whether accepted sockets are non-blocking or not
regardless of how they were created.

* ext/socket/init.c (cloexec_accept): support nonblock flag and
  use SOCK_NONBLOCK if possible
* ext/socket/init.c (rsock_s_accept_nonblock): update cloexec_accept call
* ext/socket/init.c (accept_blocking): ditto for blocking
* test/socket/test_nonblock.rb: check nonblock? on accepted socket
  [Feature #11138]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-17 05:56:07 +00:00
nobu b837025d77 ifaddr.c: wrapper object before alloc
* ext/socket/ifaddr.c (rsock_getifaddrs): make wrapper object
  before result structs allocation and manage refcount for each
  elements to get rid of potential memory leak.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50512 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-16 12:57:17 +00:00
nobu 6fb9349d85 allocate structs with wrapper
* parse.y (rb_parser_new, ripper_s_allocate): allocate structs
  with making new wrapper objects and get rid of potential memory
  leak.

* variable.c (rb_autoload): ditto.

* ext/digest/digest.c (rb_digest_base_alloc): ditto.

* ext/strscan/strscan.c (strscan_s_allocate): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50511 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-16 12:56:48 +00:00
nobu ecbad6dfa8 gc.c: rename alloc as wrap
* gc.c (rb_data_object_wrap, rb_data_typed_object_wrap): rename
  alloc as wrap.  these functions do not allocate data pointers
  but just wrap the given pointers.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50506 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-16 12:17:14 +00:00
hsbt 180293ac89 * ext/pathname/lib/pathname.rb: Remove condition of RUBY_VERSION <= 1.9.
[Feature #11082]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50490 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-14 06:54:22 +00:00
glass d88957abad * ext/zlib/zlib.c (rb_gzreader_external_encoding):
define GzipReader#external_encoding.
  [Bug #10900]

* test/zlib/test_zlib.rb: test for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50460 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-10 03:43:22 +00:00
glass 0c14c3ab0b * ext/win32ole/win32ole_variant.c: fix typo "indicies".
the patch is from davydovanton <antondavydov.o at gmail.com>.
  [fix GH-892]

* lib/rubygems/indexer.rb: ditto.

* test/rubygems/test_gem_indexer.rb: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50459 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-10 03:01: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
nobu 596663589b extconf.rb: no nmake style VPATH
* ext/io/console/extconf.rb: only nmake needs remove  style VPATH.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-08 08:22:06 +00:00
nobu d75ba7dc3e depend: no nmake style VPATH
* ext/io/console/depend: remove nmake style VPATH, for normal makes.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50446 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-08 08:05:45 +00:00
nobu 8869cdf576 checksum.rb: check the target
* tool/checksum.rb (Checksum#update?): check if the target exists
  too.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-07 07:09:43 +00:00
nobu 19e0fa010e win32_vk.inc: renamed
* ext/io/console/win32_vk.inc: renamed not to be included in HDRS
  by mkmf.rb and regenerated unexpectedly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50437 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-07 06:35:40 +00:00
nobu 81c83f55e7 io/console: win32_vk dependencies
* ext/io/console/depend: check if VK table is modified by the
  checksum.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50434 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-06 21:54:07 +00:00
normal 84b012e02a stdlib: use IO#wait_*able instead of IO.select when possible
In case a process encounters high-numbered FDs, this allows
consistent performance on systems with ppoll support.
[ruby-core:35572]

* ext/socket/lib/socket.rb (connect_nonblock): use IO#wait_writable
* lib/drb/drb.rb (DRB::DRbTCPSocket#alive?): use IO#wait_readable
* lib/webrick/httpserver.rb (run): ditto
* lib/resolv.rb (request): ditto for single socket case
  [ruby-core:68943] [Feature #11081]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50432 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-06 20:30:43 +00:00
nobu c1e7d5f5bd io/console: vk_header only on Windows
* ext/io/console/extconf.rb: vk_header is used only on Windows,
  nonsense to update on other platforms.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-05 10:54:37 +00:00
nobu 11b97855c4 console.c: pressed? on Windows
* ext/io/console/console.c (console_key_pressed_p): new method
  IO#pressed? on Windows.  [EXPERIMENTAL]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50427 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-03 18:13:10 +00:00
nobu 85366d7d59 console.c: cursor position on Windows
* ext/io/console/console.c (console_goto): new method IO#goto on
  Windows.  [EXPERIMENTAL]

* ext/io/console/console.c (console_cursor_pos): new method
  IO#cursor on Windows.  [EXPERIMENTAL]

* ext/io/console/console.c (console_cursor_set): new method
  IO#cursor= on Windows.  [EXPERIMENTAL]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50425 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-03 18:11:40 +00:00
nobu 1014dfb442 console.c: IO#beep
* ext/io/console/console.c (console_beep): new method IO#beep.
  [EXPERIMENTAL]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-03 18:11:25 +00:00
odaira fadd0160d0 * ext/-test-/file/fs.c: need to include sys/statvfs.h
to use statvfs().

* ext/-test-/file/extconf.rb: check the existence of
  sys/statvfs.h

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50423 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-03 13:54:54 +00:00
nobu 3cfd6f9fcd console.c: remove old ifdef
* ext/io/console/console.c (LAST_ERROR): remove old ifdef, should
  use rb_w32_map_errno always.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50419 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-03 00:35:35 +00:00
nobu 03c19dc555 ipsocket.c: fix merge miss
* ext/socket/ipsocket.c (init_inetsock_internal): fix local
  variable name by merge miss.  [ruby-core:68531] [Bug #10975]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50405 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-30 07:45:36 +00:00
nobu db7a4e66e1 ipsocket.c: sys_error
* ext/socket/ipsocket.c (init_inetsock_internal): preserve errno
  before other library calls and use rb_syserr_fail.
  [ruby-core:68531] [Bug #10975]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50404 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-30 07:39:46 +00:00
normal 46acbe9ddd socket: avoid common exceptions when calling connect_nonblock
Errno::EISCONN and IO::WaitReadable exceptions are common,
expensive, and noisy under normal use.  Avoid raising on them
since they are not exceptional.

* ext/socket/lib/socket.rb (connect_internal): avoid common exceptions
  from connect_nonblock. [ruby-core:68909]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50363 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-20 20:46:08 +00:00
hsbt 325a50fc57 * ext/openssl/*: use license instead of licence.
[fix GH-876][ci skip] Patch by @davydovanton
* lib/net/https.rb: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50351 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-20 03:55:09 +00:00
normal b88296be43 connect_nonblock(..., exception: false) does not raise EISCONN
* ext/socket/socket.c (sock_connect_nonblock): do not raise EISCONN
  [ruby-core:68926] [Feature #11072]
* test/socket/test_nonblock.rb: check non-EISCONN on 2nd connect

This is to reduce exceptions for code which issues a
(IMHO, unnecessary) second connect() syscall.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50347 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-20 02:11:10 +00:00
nobu 038c0e5a80 ext: suppress warnings
* ext/{etc,openssl,tk}: Adding parens and comparisons around
  assignments to get rid of Wparentheses warnings.  [Fix GH-875]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-19 03:19:20 +00:00
nobu 5c0df05b92 parser.rl: define enc_raise iff necessary
* ext/json/parser/parser.rl (enc_raise): no needs if rb_enc_raise
  is available.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50343 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-18 06:24:38 +00:00
nobu b38c0b7974 parser.rl: rb_enc_raise
* ext/json/parser/parser.rl: raise with messages in UTF-8
  encoding.  [ruby-core:67386] [Bug #10705]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50342 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-18 06:19:52 +00:00
nobu f47dc0738a parser.rl: use rb_encoding
* ext/json/parser/parser.rl (convert_encoding): use rb_encoding
  functions to compare and convert encodings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50340 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-18 06:18:50 +00:00
nobu 6583e5dbfa parser.rl: use StringValue
* ext/json/parser/parser.rl (cParser_initialize): use StringValue
  instead of direct rb_convert_type and remove duplicate
  conversion.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50339 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-18 06:18:37 +00:00
nobu c35aa93590 tkutil.c: revert r48250
* ext/tk/tkutil/tkutil.c (Init_tkutil): TkUtil::CallbackSubst and
  TkUtil::CallbackSubst::Info need the default allocator.
  [ruby-list:50115]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50338 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-17 05:07:58 +00:00
nobu 684fe92dcc nofree.c: Bug::String.nofree
* ext/-test-/string/nofree.c: new method for test of r50334.
  [ruby-core:68436] [Bug #10942]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-17 03:55:53 +00:00
hsbt d9a2b3480e * doc/contributors.rdoc: fix a typo. Patch by @davydovanton
[fix GH-872][ci skip]
* doc/syntax/methods.rdoc: ditto.
* ext/digest/sha2/sha2.c: ditto.
* ext/socket/ipsocket.c: ditto.
* ext/tk/*: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50320 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-15 01:37:47 +00:00
nobu 760ae4a8b9 win32ole.c: use rb_sym2str
* ext/win32ole/win32ole.c: use rb_sym2str when the result strings
  will not be modified.

* ext/win32ole/win32ole_event.c: ditto.

* ext/win32ole/win32ole_record.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50311 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-14 03:36:40 +00:00
nobu 659f14b254 tkutil.c: fallback rb_id2str
* ext/tk/tkutil/tkutil.c (rb_id2str): add fallback definition.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50310 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-14 03:36:19 +00:00
nobu 0b2554fe7e tkutil.c: use rb_sym2str
* ext/tk/tkutil/tkutil.c (rb_sym2str): use rb_sym2str always but
  not rb_sym_to_s, and fallback to rb_id2str and SYM2ID.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-14 03:35:54 +00:00
nobu 523ecd29b8 use frozen string of symbols
* range.c (range_step, range_each): String#upto should never
  modifies the receiver, use frozen strings to enumerate symbols.

* re.c (reg_operand): matching target is not modified.

* ext/socket/constants.c (constant_arg): str_to_int never modifies
  argument strings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50306 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-14 03:31:28 +00:00
nobu 3dba6dabb6 printf.c: uint_to_str
* ext/-test-/printf/printf.c (uint_to_str): renamed to get rid of
  conflict on cygwin.  [ruby-core:68877] [Bug #11065]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50305 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-14 02:25:27 +00:00
nagachika 599bfa7233 * ext/openssl/lib/openssl/ssl.rb: stricter hostname verification
following RFC 6125. with the patch provided by Tony Arcieri and
  Hiroshi Nakamura [ruby-core:61545] [Bug #9644]
* test/openssl/test_ssl.rb: add tests for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50292 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-13 13:09:18 +00:00
hsbt 1bc5669857 * ext/json/json.gemspec: bump version to 1.8.2.
* ext/json/lib/json/version.rb: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50270 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-12 09:40:11 +00:00
hsbt 9829e91d34 * ext/json/json.gemspec, lib/rdoc/rdoc.gemspec: added gemspec directly.
* defs/default_gems, tool/rbinstall.rb: removed default_gems definition.
  it make simple installation for default gems.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50269 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-12 09:12:15 +00:00
hsbt 2e4f0af00f * ext/json/*, test/json/*: Reverted r50231. Because it's not works with
cross-compile environment.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50267 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-12 08:36:37 +00:00
nobu a60e00fde8 wait.c: no EOF
* ext/io/wait/wait.c (io_wait_readable): simply returns that IO is
  readable without blocking, but no longer returns EOF.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50263 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-12 06:10:21 +00:00
nobu 1baa57b003 wait.c: poll over nread
* ext/io/wait/wait.c (io_ready_p, io_wait_readable): try polling
  first and check FIONREAD optionally to see if EOF.
  [ruby-core:36805] [Feature #4849]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50262 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-12 06:08:39 +00:00
nobu a4f7274423 wait.c: fix rdoc
* ext/io/wait/wait.c (io_wait_writable): fix rdoc.  no EOF to
  write.  retursn nil when timeout, not self.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-12 06:07:48 +00:00
hsbt f662d31b6b * ext/coverage/coverage.c: Remove extension from require argument.
[ci skip][fix GH-870] Patch by @yui-knk

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-12 04:52:23 +00:00
normal c18df6d87c connect_nonblock supports "exception: false"
This is for consistency with accept_nonblock arguments and gives a
minor speedup from avoiding exceptions.
[ruby-core:68838] [Feature #11024]

* ext/openssl/ossl_ssl.c (ossl_ssl_connect_nonblock):
  support `exception: false'
* (get_no_exception): move function location
* ext/socket/socket.c (sock_connect_nonblock):
  support `exception: false'
* test/openssl/test_pair.rb (test_connect_accept_nonblock_no_exception):
  test `exception: false' on connect,
  rename from `test_accept_nonblock_no_exception'
* test/socket/test_nonblock.rb (test_connect_nonblock_no_exception):
  new test

Benchmark results:

default            0.050000   0.100000   0.150000 (  0.151307)
exception: false   0.030000   0.080000   0.110000 (  0.108840)

----------------------------8<-----------------------
require 'socket'
require 'benchmark'
require 'io/wait'
require 'tmpdir'

host = '127.0.0.1'
serv = TCPServer.new(host, 0) # UNIX sockets may not hit EINPROGRESS

nr = 5000 # few iterations to avoid running out of ports

addr = serv.getsockname
pid = fork do
  begin
    serv.accept.close
  rescue => e
    warn "#$$: #{e.message} (#{e.class})"
  end while true
end
at_exit { Process.kill(:TERM, pid) }
serv.close

Benchmark.bmbm do |x|
  x.report("default") do
    nr.times do
      s = Socket.new(:INET, :STREAM)
      s.setsockopt(:SOL_SOCKET, :SO_REUSEADDR, 1)
      begin
        s.connect_nonblock(addr)
      rescue IO::WaitWritable
        s.wait_writable
      end
      s.close
    end
  end
  x.report("exception: false") do
    nr.times do
      s = Socket.new(:INET, :STREAM)
      s.setsockopt(:SOL_SOCKET, :SO_REUSEADDR, 1)
      case s.connect_nonblock(addr, exception: false)
      when :wait_writable
        s.wait_writable
      end
      s.close
    end
  end
end

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