aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-09-09 17:29:12 +0000
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-09-09 17:29:12 +0000
commit84c77c15205d57a3d50d8b29bb6d2af2ff44de77 (patch)
treea4ef2343ecfe090340d71d082b34d1b69a35ca7a /io.c
parent946f7fc7888f61da879c660b43e2c574aaf713eb (diff)
downloadruby-84c77c15205d57a3d50d8b29bb6d2af2ff44de77.tar.gz
* ext/socket/basicsocket.c (rsock_bsock_send):
avoid unnecessary select() calls before doing I/O Patch by Eric Wong. [Feature #4538] [ruby-core:35586] * ext/socket/init.c (rsock_s_recvfrom): ditto. * ext/socket/init.c (rsock_s_accept): ditto. * ext/socket/udpsocket.c (udp_send): ditto. * io.c (io_fflush): ditto. * io.c (io_binwrite): ditto. * io.c (rb_io_syswrite): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36944 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/io.c b/io.c
index 57f5775c41..24f141c825 100644
--- a/io.c
+++ b/io.c
@@ -975,9 +975,7 @@ io_fflush(rb_io_t *fptr)
rb_io_check_closed(fptr);
if (fptr->wbuf.len == 0)
return 0;
- if (!rb_thread_fd_writable(fptr->fd)) {
- rb_io_check_closed(fptr);
- }
+ rb_io_check_closed(fptr);
while (fptr->wbuf.len > 0 && io_flush_buffer(fptr) != 0) {
if (!rb_io_wait_writable(fptr->fd))
return -1;
@@ -1132,7 +1130,12 @@ io_binwrite(VALUE str, const char *ptr, long len, rb_io_t *fptr, int nosync)
(fptr->wbuf.ptr && fptr->wbuf.capa <= fptr->wbuf.len + len)) {
struct binwrite_arg arg;
- /* xxx: use writev to avoid double write if available */
+ /*
+ * xxx: use writev to avoid double write if available
+ * writev may help avoid context switch between "a" and "\n" in
+ * STDERR.puts "a" [ruby-dev:25080] (rebroken since native threads
+ * introduced in 1.9)
+ */
if (fptr->wbuf.len && fptr->wbuf.len+len <= fptr->wbuf.capa) {
if (fptr->wbuf.capa < fptr->wbuf.off+fptr->wbuf.len+len) {
MEMMOVE(fptr->wbuf.ptr, fptr->wbuf.ptr+fptr->wbuf.off, char, fptr->wbuf.len);
@@ -1146,11 +1149,8 @@ io_binwrite(VALUE str, const char *ptr, long len, rb_io_t *fptr, int nosync)
return -1L;
if (n == 0)
return len;
- /* avoid context switch between "a" and "\n" in STDERR.puts "a".
- [ruby-dev:25080] */
- if (fptr->stdio_file != stderr && !rb_thread_fd_writable(fptr->fd)) {
- rb_io_check_closed(fptr);
- }
+
+ rb_io_check_closed(fptr);
arg.fptr = fptr;
arg.str = str;
retry:
@@ -4323,9 +4323,6 @@ rb_io_syswrite(VALUE io, VALUE str)
if (fptr->wbuf.len) {
rb_warn("syswrite for buffered IO");
}
- if (!rb_thread_fd_writable(fptr->fd)) {
- rb_io_check_closed(fptr);
- }
n = rb_write_internal(fptr->fd, RSTRING_PTR(str), RSTRING_LEN(str));