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

1157 Коммитов

Автор SHA1 Сообщение Дата
nobu fb8ff8de93 * io.c (rb_write_error2): fwrite() returns ssize_t.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33884 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-28 03:57:31 +00:00
usa 02f9b4d606 * io.c (rb_io_flush): release GVL during fsync() on Windows.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33878 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-28 02:47:51 +00:00
kosaki 8cee31214d * io.c (rb_write_error2): get rid of warning on linux. fwrite
of glibc is tagged __attribute__ ((__warn_unused_result__))
  if _FORTIFY_SOURCE != 0.
* vm_dump.c (rb_vm_bugreport): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33871 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-27 12:06:10 +00:00
akr 5f652716ca * io.c (copy_stream_body): use 0666 for permission argument for open.
[ruby-core:40865]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33851 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-26 15:18:05 +00:00
kosaki aa23f6b9fd * io.c (ioctl_narg_len, linux_iocparm_len): reinstantiate linux
specific narg length calculation.
* test/ruby/test_io.rb (test_ioctl_linux2): add new test for old and
  unstructured ioctl.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33839 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-25 02:45:50 +00:00
akr bee4e843ce * io.c (rb_io_reopen): re-initialize buffereing mode for stdout and
stderr.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33828 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-24 11:00:35 +00:00
kosaki d7166624bf Merge branch 'fsync-nogvl' into trunk
Conflicts:
	ChangeLog

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-24 02:57:57 +00:00
naruse fd8d9d9dce * io.c (ioctl_narg_len): don't use _IOC_SIZE macro on Linux.
On Linux some constants for ioctl(2) doesn't include the size of
  its return value and 16bit value; for example FIONREAD 0x541B.
  Moreover the manual, ioctl_list(2),  says "Note  that  the  size
  bits  are  very unreliable: in lots of cases they are wrong,
  either because of buggy macros using sizeof(sizeof(struct)),
  or because of legacy values."
  So we shouldn't use it.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-23 11:24:49 +00:00
akr 08f8dfc20b * io.c (linux_get_maxfd): get rid of a warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33806 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-21 15:26:12 +00:00
akr f49f6ff1d7 * io.c (linux_get_maxfd): new function to find maximum fd on Linux.
(rb_close_before_exec): use linux_get_maxfd.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33805 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-21 14:40:09 +00:00
usa 44cff77b95 * io.c (rb_cloexec_open): set O_NOINHERIT instead of O_CLOEXEC if it is
available (for Windows).

* win32/win32.c (fcntl): on F_DUPFD, determine the inheritance of the
  new handle by O_NOINHERIT flag of original fd.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-18 04:06:01 +00:00
usa bbe004c1e4 * io.c (argf_next_argv): wrong timing of setting ecflags.
fixed the failure of TestArgf#test_textmode introduced at r33662.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33770 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-16 02:36:08 +00:00
akr 3d25acdccc * io.c, thread.c, ext/pty/pty.c, ext/fiddle/closure.c: use
__linux__ macro for consistency.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-15 11:09:47 +00:00
nobu 80c32b2330 * io.c (do_ioctl, ioctl_narg_len, setup_narg, rb_ioctl): use
ioctl_req_t.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33727 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-12 08:26:13 +00:00
nobu 9998578951 * ChangeLog, io.c: whitespace-cleanup.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-12 07:49:48 +00:00
kosaki 33817fbc29 * io.c (fcntl_narg_len): introduce narg calculation for fcntl instead
of hard coded 256.
* io.c (setup_narg): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33721 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-12 02:33:58 +00:00
kosaki 791f5449c1 * io.c (ioctl_narg_len): Linux doesn't have IOCPARM_LEN macro, but
has _IOC_SIZE. support it.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33718 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-12 02:29:37 +00:00
kosaki b3027d5929 * io.c (rb_ioctl): don't expose our sanity check value to ruby script.
It may change string value meaning if the value is string.
  (e.g. MacOS X has  F_GETPATH ioctl)
* io.c (rb_fcntl): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33717 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-12 02:27:51 +00:00
kosaki 7e2f0491ce * io.c (ioctl_req_t): Type of req argument of ioctl() depend on platform.
Moreover almost all linux ioctl can't be represented by 32bit integer
  (i.e. MSB is 1). We need wrap ioctl argument type.
[Bug #5429] [ruby-dev:44589]
* io.c (struct ioctl_arg): ditto.
* io.c (rb_ioctl): ditto.
* test/ruby/test_io.rb (test_ioctl_linux): add a testcase for ioctl



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-12 02:24:51 +00:00
kosaki fc7bb927a2 * io.c (struct io_cntl_arg): remove io_p member.
* io.c (nogvl_fcntl, do_fcntl, rb_fcntl): separated from ioctl functions.
* io.c (nogvl_io_cntl): remove fcntl depended logic.
* io.c (io_cntl): ditto.
* io.c (rb_io_ctl): ditto.
* io.c (rb_io_ioctl): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-12 02:17:41 +00:00
kosaki f13d10a0af * io.c (setup_narg): fix off by one bug.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-12 02:12:19 +00:00
kosaki eec252e2e5 * io.c (+setup_narg): factor out length calculation logic.
* io.c (rb_io_ctl): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-12 02:09:56 +00:00
kosaki 9d16ad639f * io.c (+ioctl_narg_len) new helper function.
* io.c (rb_io_ctl): don't use ioctl specific length check
  if caller is fcntl.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33711 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-12 02:06:23 +00:00
kosaki 0d746627af * io.c (pipe_open): Remove fflush(stdin). it's no effect.
Pointed out by Ikegami Daisuke <ikegami.da@gmail.com>.
  Thank you.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33704 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-11 03:41:13 +00:00
nobu 1393e55d09 * io.c (rb_update_max_fd): fstat(2) can fail with other than
EBADF.  [ruby-dev:44837] [Backport #4339].  Cf.
  http://pubs.opengroup.org/onlinepubs/9699919799/functions/fstat.html

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-09 14:20:27 +00:00
nobu 42b4255d08 * io.c (rb_sysopen): max fd is updated in rb_sysopen_internal()
already.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-09 13:54:33 +00:00
usa 53881a8c6d * io.c (io_fwrite): call rb_w32_write_console() only if FMODE_TTY is
set.  this is the one of the reason of IO writing slowness of Windows
  in 1.9.3 or later.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33667 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-08 05:52:32 +00:00
akr bd3b3c1b51 update doc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33664 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-07 21:01:40 +00:00
usa add77a592b * include/ruby/encoding.h (ECONV_NEWLINE_DECORATOR_READ_MASK,
ECONV_NEWLINE_DECORATOR_WRITE_MASK): new macro.

* io.c (rb_io_extract_modeenc, pipe_open, prep_stdio, argf_next_argv):
  set TEXTMODE_NEWLINE_DECORATOR_ON_WRITE for textmode on creating IO
  if the flag is available.

* io.c (make_writeconv): drop decorators for reading.

* io.c (make_readconv): drop decorators for writing.

* io.c (do_writeconv): existing writeconv is not the condition to raise
  ArgumentError.  should check textmode or not.

* test/ruby/test_io_m17n.rb
  (TestIO_M17N#test_{cr,lf,crlf}_decorator_on_stdout): test above
  changes.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-07 17:48:11 +00:00
usa 66595f3894 * io.c (io_fflush): remove fsync().
* io.c (rb_io_flush, rb_io_rewind): fsync() here.

these changes reduces fsync() calls to improve performance.
first reported at [ruby-list:48515] by ak7 at mail.goo.ne.jp .
[Bug #5585]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-07 11:08:39 +00:00
akr 987c03a387 * io.c (rb_close_before_exec): use F_MAXFD if available.
F_MAXFD is available on NetBSD since NetBSD 2.0.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-07 10:44:02 +00:00
akr 333c847f19 * io.c (rb_cloexec_fcntl_dupfd): don't clear try_dupfd_cloexec if
fcntl(F_DUPFD) failed as fcntl(F_DUPFD_CLOEXEC).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-05 10:13:00 +00:00
nobu 413f24d3b0 * whitespace cleanup.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-04 07:19:23 +00:00
usa a3ce319639 * io.c (make_writeconv): fixed typo of previous commit.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33629 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-03 19:06:43 +00:00
usa 102ec1171d * io.c (make_writeconv): fixed typo of previous commit.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33628 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-03 18:45:41 +00:00
usa 932d63efe0 * io.c (make_writeconv): unversal_newline converter is for reading.
so, if the io is text mode and has ECONV_UNIVERSAL_NEWLINE_DECORATOR
  flag, use crlf_newline converter for writing.
  this change fixes the problem about the luck of CR up Kernel.p and
  Kernel.puts to stdout/stderr on Windows.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-03 16:59:53 +00:00
naruse f0bd639693 * io.c (rb_cloexec_pipe): remove workaround of r33587.
The bug of NetBSD is fixed on Mon Oct 31 21:31:29 UTC 2011.
  http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=45545

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33606 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-01 12:43:47 +00:00
akr 809006f407 * io.c (rb_io_reopen): call rb_fd_fix_cloexec instead of
rb_maygvl_fd_fix_cloexec.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33605 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-01 10:49:40 +00:00
akr 89a1258110 * io.c (rb_io_reopen): call rb_maygvl_fd_fix_cloexec after freopen().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-01 10:01:01 +00:00
naruse f926980902 * io.c (nogvl_io_cntl): rb_cloexec_fcntl_dupfd's 2nd argument is int.
* process.c (move_fds_to_avoid_crash): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33602 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-01 05:56:51 +00:00
akr c16f98ab0a * io.c (rb_maygvl_fd_fix_cloexec): renamed from fd_set_cloexec.
* internal.h (rb_maygvl_fd_fix_cloexec): declared.

* ext/socket/init.c (cloexec_accept): use rb_maygvl_fd_fix_cloexec.
  (rsock_s_accept_nonblock): use rb_update_max_fd.
  (rsock_s_accept): use rb_update_max_fd.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33598 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-01 03:04:03 +00:00
akr 24176a8d5d add comment.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-31 23:24:25 +00:00
naruse 6a96646de2 Fix previous commit (r33586).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33588 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-31 13:50:32 +00:00
naruse ca6311b0b5 * io.c (rb_cloexec_pipe): NetBSD 6.0 will support pipe2(2),
but its return value is -1 or larger than 0.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33587 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-31 13:21:03 +00:00
akr 1a70dfe6f4 * include/ruby/intern.h (rb_fd_fix_cloexec): renamed from
rb_fd_set_cloexec.

* io.c: follow the above renaming.

* 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@33585 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-31 12:49:16 +00:00
akr 687c41dc4d * io.c (fd_set_cloexec): clear CLOEXEC flag for standard file
descriptors.
  (rb_cloexec_dup): use rb_cloexec_fcntl_dupfd.
  (rb_cloexec_fcntl_dupfd): use F_DUPFD_CLOEXEC if available.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-31 11:17:15 +00:00
akr da5ae5544d * io.c (rb_cloexec_dup2): check oldfd == newfd at first.
pointed by KOSAKI Motohiro.  [ruby-dev:44713]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33579 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-31 03:07:26 +00:00
usa bdc85361e4 * io.c (rb_cloexec_fcntl_dupfd): this function needs F_DUPFD.
* io.c (nogvl_io_cntl): use rb_cloexec_fcntl_dupfd() only if the
  platform has F_DUPFD.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33578 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-31 01:52:21 +00:00
akr 5c19f07700 * include/ruby/intern.h (rb_cloexec_fcntl_dupfd): declared.
* io.c (rb_cloexec_fcntl_dupfd): new function.
  (nogvl_io_cntl): use rb_cloexec_fcntl_dupfd.

* process.c (move_fds_to_avoid_crash): use rb_cloexec_fcntl_dupfd.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33575 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-30 15:17:27 +00:00
akr e7f8c03818 * configure.in: check pipe2.
* io.c (rb_cloexec_pipe): use pipe2 if available.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33574 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-30 13:48:35 +00:00