aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
Commit message (Collapse)AuthorAgeFilesLines
* * io.c (rb_update_max_fd): validate fd.akr2011-07-231-0/+4
| | | | | | | | | | | | | | | | | | * ext/socket/rubysocket.h (rsock_discard_cmsg_resource): add msg_peek_p argument for the declaration. * ext/socket/ancdata.c (discard_cmsg): add msg_peek_p argument. assume FreeBSD, NetBSD and MacOS X doesn't generate passed fd when MSG_PEEK. (rsock_discard_cmsg_resource): add msg_peek_p argument. (bsock_recvmsg_internal): call rsock_discard_cmsg_resource with msg_peek_p argument. * ext/socket/unixsocket.c (unix_recv_io): call rsock_discard_cmsg_resource with msg_peek_p argument. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32638 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (rb_update_max_fd): remove parentheses. they are not in macro.kazu2011-07-201-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32588 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/intern.h (rb_update_max_fd): declaration moved fromakr2011-07-201-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | internal.h. * file.c: ditto. * io.c: call rb_update_max_fd for each new fds. * process.c: ditto. * random.c: ditto. * ruby.c: ditto. * ext/io/console/console.c: ditto. * ext/openssl/ossl_bio.c: ditto. * ext/pty/pty.c: ditto. * ext/socket/init.c: ditto. * ext/socket/socket.c: ditto. * ext/socket/ancdata.c: ditto. * ext/socket/unixsocket.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32587 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (UPDATE_MAXFD): removed.akr2011-07-191-11/+7
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32581 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (rb_update_max_fd): new function.akr2011-07-191-0/+5
| | | | | | | | | | | * internal.h (rb_update_max_fd): declare rb_update_max_fd. * thread_pthread.c (rb_thread_create_timer_thread): update max fd when timer thread pipe is created. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32579 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * win32/win32.c, include/ruby/win32.h (rb_w32_io_cancelable_p): renamedusa2011-07-151-1/+1
| | | | | | | | | | | | | from rb_w32_has_cancel_io(). now it takes a parameter as fd to check the fd is console or not, because we cannot cancel console input even if we have cancel_io function. * io.c (WAIT_FD_IN_WIN32): call above function instead of the old one, so now we can kill the thread which calls STDIN.gets. the problem was reported by ko1 vir IRC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32549 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c: Note that methods other than IO#gets may increase IO#lineno.drbrain2011-07-091-5/+8
| | | | | | | [Ruby 1.9 - Bug #4902] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32465 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (rb_io_close): close(2) on a fd which is being read bynobu2011-07-081-0/+6
| | | | | | another thread causes deadlock on Mac OS X 10.5 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/intern.h, thread_pthread.c (rb_reserved_fd_p,ko12011-07-031-0/+3
| | | | | | | | | | | | | | | | | | | | RB_RESERVED_FD_P): added. This C API is to limit to access fds which are used by RubyVM internal. In this version of CRuby, return 1 if fd is communication pipe. If your application needs to close all file descriptors to preent resource leak, skip internal fds using this C API. We also define a macro RB_RESERVED_FD_P(fd). So you can write #ifndef RB_RESERVED_FD_P #define RB_RESERVED_FD_P(fd) 0 #endif for Ruby 1.9.2 or previous version to write compatible extensions. See [ruby-core:37727] * thread_win32.c (rb_reserved_fd_p): added (return 0 for any fds). * io.c (rb_io_initialize): raise ArgumentError if given fd is reserved by Ruby. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32394 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * math.c: Attach documentation for Math.drbrain2011-06-291-3/+11
| | | | | | | | | | | | | | | | | | | | * object.c: Document NIL, TRUE, FALSE. * io.c: Improve grammar in ARGF comment. Document STDIN/OUT/ERR. Document ARGF global constant. * lib/rake: Hide deprecated toplevel constants from RDoc (import from rake trunk). * lib/thwait.rb: Document ThWait. * lib/mathn.rb: Hide Math redefinition from RDoc * lib/sync.rb: Add a basic comment for Sync_m, Synchronizer_m, Sync, Synchronizer. * parse.y: Document SCRIPT_LINES__. * hash.c: Document ENV class and global constant. * vm.c: Document TOPLEVEL_BINDING. * version.c: Document RUBY_* constants. * ruby.c: Document DATA and ARGV. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32281 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (fill_cbuf): finish reading at EOF, and the readconv hasnobu2011-06-181-0/+3
| | | | | | | | been cleared by another thread while io_fillbuf() is waiting at select(). a patch in [ruby-core:37197] by Hiroshi Shirosaki <h.shirosaki AT gmail.com>. fixed #3840 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c: supress warnings.akr2011-06-181-2/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32159 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h: declare internal functions here.akr2011-06-171-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | * node.h: declare NODE dependent internal functions here. * iseq.h: declare rb_iseq_t dependent internal functions here. * vm_core.h: declare rb_thread_t dependent internal functions here. * bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c, enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c, iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y, proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c, thread.c, time.c, transcode.c, variable.c, vm.c, tool/compile_prelude.rb: don't declare internal functions declared in above headers. include above headers if required. Note that rb_thread_mark() was declared as void rb_thread_mark(rb_thread_t *th) in cont.c but defined as void rb_thread_mark(void *ptr) in vm.c. Now it is declared as the later in internal.h. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c: Improve documentation of IO and File open and new.drbrain2011-06-161-67/+71
| | | | | | | Patch by Roger Pack. [Ruby 1.9 - Bug #4790] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c: use select() appropriately for sendfile().akr2011-06-121-17/+12
| | | | | | | | | | | Fixed by Eric Wong. [ruby-core:36150] (maygvl_copy_stream_wait_readwrite): removed. (nogvl_copy_stream_sendfile): use nogvl_copy_stream_wait_write and maygvl_copy_stream_wait_read instead of maygvl_copy_stream_wait_readwrite. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32019 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (io_getc): should be 7bit if ascii. fixes #4557nobu2011-06-111-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32000 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c: fix IO.copy_stream interrupt handling.akr2011-06-091-22/+82
| | | | | | | | | | | | | | | | based on the patch by Eric Wong. [ruby-core:36156] * vm_core.h (rb_thread_call_with_gvl): don't declare here. * thread.c: include internal.h. (rb_thread_execute_interrupts): new function. * internal.h (rb_thread_execute_interrupts): declared. (rb_thread_call_with_gvl): declared. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (io_fflush): windows -- call fsync() only when the FD is tied tousa2011-06-031-1/+5
| | | | | | | file, because if the FD is pipe, it blocks. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (rb_io_s_write, rb_io_s_binwrite): return!!!usa2011-06-021-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31905 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c: Add File.write, File.binwrite. [Feature #1081] [ruby-core:21701]sorah2011-06-021-0/+126
| | | | | | | | * test/ruby/test_io.rb: Test for File.write, File.binwrite. * NEWS: News for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31902 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (io_flush, rb_io_flush): need to fsync() when ruby calls internalusa2011-06-021-3/+3
| | | | | | | flush. [ruby-core:36670] [Bug #4813] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31901 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* doco: p outputs newline regardless of record separatorryan2011-06-011-3/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31883 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (io_encoding_set): should honor already set ecflags since itnobu2011-05-311-5/+3
| | | | | | might be set by mode option. fixed #4804 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* no space inside parensnobu2011-05-311-8/+8
| | | | | | * io.c: remove spaces before closing parens. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31866 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (rb_io_s_pipe): potential bug. the mode of read IO is set asusa2011-05-311-0/+8
| | | | | | | | | | DEFAULT_TEXTMODE in call of io_set_encoding(), and of write IO is also set as it in call of io_new_instance() via rb_protect(). so, if DEFAULT_TEXTMODE is not 0, we should check the result of extract_binmode() and avoid crush of default IO mode and the result. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31859 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (fill_cbuf): return MORE_CHAR_SUSPENDED when cbuf is not empty.naruse2011-05-271-0/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31758 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (fill_cbuf): Fix test-all crash.kosaki2011-05-271-1/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (validate_enc_binmode): do not clear textmode flag ifnobu2011-05-271-0/+2
| | | | | | default. fixed #4732 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31748 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (fill_cbuf): finish reading at EOF.nobu2011-05-271-0/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (rb_io_extract_modeenc): accept combination hash andkosaki2011-05-211-1/+1
| | | | | | | | | | File::Constants. (eg. File.open('yo', :mode => File::WRONLY)) [Feature #4742][ruby-core:36338] * test/ruby/test_io.rb (TestIO#test_open_mode): new test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* revert O_CLOEXEC patch series completely.kosaki2011-05-191-4/+0
| | | | | | | | | | because boron chkbuild test result says, An old linux kernel ignore O_CLOEXEC silently instead of return an error. It may lead to bring new security risk. So, we have to be pending it until finish to implement proper fallback logic. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31643 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * remove trailing spaces.nobu2011-05-151-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (select_internal): remove unused variable (interrupt_flag).kosaki2011-05-121-35/+32
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31533 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (Init_IO): Added File::CLOEXEC constant. [ruby-core:22893] [Feature ↵kosaki2011-05-041-0/+4
| | | | | | | | | | #1291] * test/ruby/test_io.rb (TestIO#test_o_cloexec): test for File::CLOEXEC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (rb_f_select): remove useless ifdef.kosaki2011-05-041-8/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31425 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * thread.c (rb_wait_for_single_fd): new.kosaki2011-05-041-40/+2
| | | | | | | | | | | | | | | | | | | | * thread.c (select_single): select(2) based backend for rb_wait_for_single_fd(). * io.c (make_writeconv): use rb_wait_for_single_fd() instaed of rb_thread_fd_select(). * io.c (rb_io_wait_readable): ditto. * thread.c (rb_thread_wait_fd_rw): ditto. * io.c (wait_readable): removed. * thread.c (init_set_fd): new helper function. * include/ruby/io.h (RB_WAITFD_IN, RB_WAITFD_PRI, RB_WAITFD_OUT): new constant for rb_single_wait_fd(). The patch was written by Eric Wong. [Ruby 1.9 - Feature #4531] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31419 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/intern.h (rb_thread_select): mark as deprecated.kosaki2011-04-301-4/+4
| | | | | | | | | | | | | * ext/io/wait/wait.c (wait_readable): use rb_thread_fd_select instead of rb_thread_select. * ext/socket/init.c (wait_connectable0): ditto. * ext/readline/readline.c (readline_event): ditto. * io.c (rb_io_wait_readable, wait_readable, rb_io_wait_writable, wait_writable): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31394 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (copy_stream_body, rb_io_s_copy_stream): move rb_fd_init()kosaki2011-04-301-1/+1
| | | | | | | | | from copy_stream_body to rb_io_s_copy_stream. fds of passing rb_fd_term() have to be guaranteed initialized. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31391 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (make_writeconv): do not add textmode newline decorator if anynobu2011-04-291-1/+2
| | | | | | newline decorator is set already. fixes #4618, fixes #4619 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31377 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (rb_io_extract_modeenc, rb_f_backquote): set default textnobu2011-04-271-2/+5
| | | | | | | mode. fixes #4619 * io.c (pipe_open): set universal newline decorator if needed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31367 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (validate_enc_binmode, rb_io_extract_modeenc): set newlinenobu2011-04-261-13/+29
| | | | | | | | decorator according to open mode. * transcode.c (rb_econv_prepare_options): new function, to prepare econv options with newline flags. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (rb_f_syscall): reduce warning: "HAVE___SYSCALL" is not defined.kazu2011-04-141-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31272 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (rb_io_fdatasync): remove unused variable.kazu2011-04-131-1/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c: revert r31230.kosaki2011-04-111-43/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (rb_io_syswrite): While local FS writes are usuallykosaki2011-04-041-1/+1
| | | | | | | | | | | buffered, the buffers can be full or the file opened with O_SYNC. IO#syswrite can also be used on blocking IOs (pipe/socket) just like IO#write. The patch is written by Eric Wong. [ruby-core:35554] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31237 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * configure.in: disable fdatasync again on Mac OS X.kosaki2011-04-031-2/+3
| | | | | | | | [ruby-core:35493][Bug #4500] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31232 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (io_reopen): IO#close releases GVL if possible.kosaki2011-04-031-4/+43
| | | | | | | | | | | | | | | | | close() may block for certain file types (NFS, SO_LINGER sockets, inotify), so let other threads run. The patch was created by Eric Wong [ruby-core:35555][Bug #4527] * io.c (fptr_finalize): ditto. * io.c (maygvl_fclose): new. * io.c (nogvl_fclose): ditto. * io.c (maygvl_close): ditto. * io.c (nogvl_close): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31230 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (io_cntl): use rb_thread_io_blocking_region() insteadkosaki2011-03-051-1/+1
| | | | | | | | rb_thread_blocking_region(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (io_cntl, nogvl_io_cntl): IO.fcntl() and IO.ioctl()kosaki2011-03-041-13/+32
| | | | | | | | | | | | release GVL during calling kernel interface. Suggested by Eric Wong. [ruby-core:35417][Bug #4463] * test/ruby/test_io.rb (TestIO#test_fcntl_lock): add new test for IO.fcntl(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (io_cntl): change 'cmd' type to int. ioctl and fcntl need tokosaki2011-03-041-3/+3
| | | | | | | | | be passed int. * io.c (rb_io_ctl): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31022 b2dd03c8-39d4-4d8f-98ff-823fe69b080e