summaryrefslogtreecommitdiff
path: root/io.c
AgeCommit message (Collapse)Author
2013-10-29* add RUBY_TYPED_FREE_IMMEDIATELY to data types which only useko1
safe functions during garbage collection such as xfree(). On default, T_DATA objects are freed at same points as fianlizers. This approach protects issues such as reported by [ruby-dev:35578]. However, freeing T_DATA objects immediately helps heap usage. Most of T_DATA (in other words, most of dfree functions) are safe. However, we turned off RUBY_TYPED_FREE_IMMEDIATELY by default for safety. * cont.c: ditto. * dir.c: ditto. * encoding.c: ditto. * enumerator.c: ditto. * error.c: ditto. * file.c: ditto. * gc.c: ditto. * io.c: ditto. * iseq.c: ditto. * marshal.c: ditto. * parse.y: ditto. * proc.c: ditto. * process.c: ditto. * random.c: ditto. * thread.c: ditto. * time.c: ditto. * transcode.c: ditto. * variable.c: ditto. * vm.c: ditto. * vm_backtrace.c: ditto. * vm_trace.c: ditto. * ext/bigdecimal/bigdecimal.c: ditto. * ext/objspace/objspace.c: ditto. * ext/stringio/stringio.c: ditto. * ext/strscan/strscan.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-20io.c: make IO#reopen("pathname") atomicnobu
* io.c (rb_io_reopen): create a new, temporary FD via rb_sysopen and call rb_cloexec_dup2 on it to atomically replace the file fptr->fd points to. This leaves no possible window where fptr->fd is invalid to userspace (even for any threads running w/o GVL). based on the patch by Eric Wong <normalperson@yhbt.net> at [ruby-core:57943]. [Bug #9036] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43373 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-08io.c: use rb_funcallvnobu
* io.c (rb_io_write): use rb_funcallv() instead of rb_funcall() to get rid of unnecessary alloca. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-06io.c: use local variables instead of struct membersnobu
* io.c (copy_stream_body): move src_io and dst_io back to top level and use instead of stp->src and stp->dst. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-06io.c: suppress false uninitialized-variable warningnobu
* io.c (io_ascii8bit_binmode): split from rb_io_ascii8bit_binmode() to call with rb_io_t* directly. * io.c (copy_stream_body): move src_io and dst_io into each blocks where those are only used. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-02io.c: wait child process after close_readnobu
* io.c (rb_io_close_read): duplex IO should wait its child process even after close_read. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-02io.c: get rid of race conditionnobu
* io.c (rb_io_close_write): detach tied IO for writing before closing to get rid of race condition. [ruby-list:49598] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43114 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-02io.c: keep fptr read-closednobu
* io.c (rb_io_close_read): keep fptr in write_io to be discarded, to fix freed pointer access when it is in use by other threads, and get rid of potential memory/fd leak. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43112 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-23[DOC]akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43022 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-22[DOC]akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-21[DOC]akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43007 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-21io.c: [DOC]nobu
* io.c (rb_io_advise): [DOC] adjust indent and fix lists. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43005 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-21io.c: [DOC]nobu
* io.c (rb_f_select): [DOC] adjust indent. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43004 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-21[DOC]akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43003 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-10* io.c (rb_f_printf): [DOC] add missing parenthesis in rdoc.kazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42901 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-27io.c: copy in binary modenobu
* io.c (copy_stream_body): should write in binary mode. based on a patch by godfat (Lin Jen-Shin) at [ruby-core:56556]. [ruby-core:56518] [Bug #8767] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42709 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-27io.c: common oflagsnobu
* io.c (copy_stream_body): move common open flags. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42708 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-26* io.c (io_read_nonblock): support non-blocking reads without raisingtenderlove
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-15* io.c, internal.h (rb_io_flush_raw): new function to select callingusa
fsync() (on Windows). * io.c (rb_io_flush_raw): use above function. * file.c (rb_file_truncate): use above function. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-15* io.c (rb_io_rewind): remove fsync() for Windows to improve theusa
performance. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42560 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-28* io.c (io_getpartial): use rb_str_locktmp_ensure().glass
[ruby-core:56121] [Bug #8669] * io.c (rb_io_sysread): ditto. * test/ruby/test_io.rb: add tests for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-28* string.c: add internal API rb_str_locktmp_ensure().glass
* io.c (io_fread): use rb_str_locktmp_ensure(). [ruby-core:56121] [Bug #8669] * test/ruby/test_io.rb: add a test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-28* io.c (interpret_seek_whence): support SEEK_DATA and SEEK_HOLE.glass
These are whences for lseek(2) supported by Linux since version 3.1. [ruby-core:56123] [Feature #8671] * test/ruby/test_io.rb: Add tests for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42211 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-16* io.c (appendline): cosmetic changeglass
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41993 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-09* io.c (appendline): use READ_CHAR_PENDING_XXX macros andglass
RSTRING_END(). * io.c (rb_io_getline_1): rewrite nested if statement into one statement. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-02io.c: use built-in encoding indexesnobu
* internal.h: add UTF-{16,32}{BE,LE}. * io.c (io_strip_bom): use built-in encoding indexes in internal.h. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41742 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-30win32: UTF-8 spawnnobu
* io.c (spawnv, spawn): use UTF-8 spawn family. [Bug #1771] * process.c (proc_exec_sh, proc_spawn_cmd, proc_spawn_sh): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41709 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-24* compile.c (make_name_for_block): use PRIsVALUE in format stringcharliesome
instead of %s and RSTRING_PTR to protect objects from being garbage collected too soon * encoding.c (str_to_encindex): ditto * hash.c (rb_hash_fetch_m): ditto * io.c (rb_io_reopen): ditto * parse.y (reg_fragment_check_gen): ditto * parse.y (reg_compile_gen): ditto * parse.y (ripper_assert_Qundef): ditto * re.c (rb_reg_raise): ditto * ruby.c (set_option_encoding_once): ditto * vm_eval.c (rb_throw_obj): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41597 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-12* safe.c (rb_set_safe_level, safe_setter): raise an ArgumentErrorshugo
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-12io.c: fix 7bit coderange conditionnobu
* io.c (io_getc): fix 7bit coderange condition, check if ascii read data instead of read length. [ruby-core:55444] [Bug #8516] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41250 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07* internal.h (numberof): Gathered from various files.akr
* array.c, math.c, thread_pthread.c, iseq.c, enum.c, string.c, io.c, load.c, compile.c, struct.c, eval.c, gc.c, parse.y, process.c, error.c, ruby.c: Remove the definitions of numberof. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-02fill rdocsnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-19fix typos. Patch by k_takata.ktsj
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13* include/ruby/ruby.h: constify RBasic::klass and addko1
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* *.c, parse.y, insns.def: use RARRAY_AREF/ASET macroko1
instead of using RARRAY_PTR(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-08* io.c (rb_io_ext_int_to_encs): ignore internal encoding if externalnaruse
encoding is ASCII-8BIT. [Bug #8342] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-26fix typo (r40195, r40428)kazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40486 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-25io.c: conversion from bom encodingnobu
* io.c (rb_io_ext_int_to_encs, parse_mode_enc): bom-prefixed name is not a real encoding name, just a fallback. so the proper conversion should take place even if if the internal encoding is equal to the bom-prefixed name, unless actual encoding is equal to the internal encoding. [ruby-core:54563] [Bug #8323] * io.c (io_set_encoding_by_bom): reset extenal encoding if no BOM found. [ruby-core:54569] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-24* io.c (rb_fd_fix_cloexec): use rb_update_max_fd().kosaki
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-23* Typo in defining EWOULDBLOCKWaitReadable on platforms whereheadius
EAGAIN != EWOULDBLOCK. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-09io.c: define EWOULDBLOCKnobu
* io.c (Init_IO): define EWOULDBLOCK alway as it is needed always. and turn runtime branch into preprocessor condition. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40203 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-08Fix #6154 by introducing new EAGAIN/EWOULDBLOCK/EINPROGRESSheadius
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-03* io.c (rb_io_seek_m): Accept :CUR, :END, :SET as "whence" argument.akr
(interpret_seek_whence): New function. [ruby-dev:45818] [Feature #6643] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40084 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-02update doc.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40064 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-29io.c: get rid of IOError when skipped while iterationnobu
* io.c (argf_next_argv): set init flag if succeeded to forward, after skipping. * io.c (argf_block_call_i, argf_block_call): no more forwarding if forwarded after skipping. [ruby-list:49185] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39997 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-29io.c: get rid of IOError when skipped while iterationnobu
* io.c (argf_close): deal with init flag. * io.c (argf_block_call_i, argf_block_call): forward next file if skipped while iteration, to get rid of IOError. [ruby-list:49185] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-19* io.c (linux_iocparm_len): enable only exist _IOC_SIZE().kosaki
Because musl libc doesn't have it. [Bug #8051] [ruby-core:53229] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39818 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-17* io.c (io_fillbuf): show fd number on failure to debug.naruse
http://c5632.rubyci.org/~chkbuild/ruby-trunk/log/20130316T050302Z.diff.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39803 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-16io.c: max_file_descriptornobu
* io.c (max_file_descriptor): rb_atomic_t for ATOMIC_CAS(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39776 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-16* include/ruby/missing.h (__syscall): moved to...kosaki
* io.c: here. because __syscall() is only used from io.c. * include/ruby/missing.h: move "#include <sys/type.h>" to .... * include/ruby/intern.h: here. because it was introduced for fixing NFDBITS issue. [ruby-core:05179]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39774 b2dd03c8-39d4-4d8f-98ff-823fe69b080e