aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-05 09:37:55 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-05 09:37:55 +0000
commit6c2108e2acbf905833834f631597fc95a615ad15 (patch)
tree7eacb9cccb364c7feb62154c5ec2df1f5e714ce5 /io.c
parent07e08245d3db1caab2cff2864510f99bf2a84ff9 (diff)
downloadruby-6c2108e2acbf905833834f631597fc95a615ad15.tar.gz
* io.c (copy_stream_fallback_body): use read method unless readpartial
is available. [ruby-dev:36124] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19148 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/io.c b/io.c
index e44d2cfe22..a82e0fd166 100644
--- a/io.c
+++ b/io.c
@@ -7216,6 +7216,13 @@ copy_stream_fallback_body(VALUE arg)
VALUE buf = rb_str_buf_new(buflen);
long rest = stp->copy_length;
off_t off = stp->src_offset;
+ ID read_method = id_readpartial;
+
+ if (stp->src_fd == -1) {
+ if (!rb_respond_to(stp->src, read_method)) {
+ read_method = id_read;
+ }
+ }
while (1) {
long numwrote;
@@ -7229,7 +7236,7 @@ copy_stream_fallback_body(VALUE arg)
l = buflen < rest ? buflen : rest;
}
if (stp->src_fd == -1) {
- rb_funcall(stp->src, id_readpartial, 2, INT2FIX(l), buf);
+ rb_funcall(stp->src, read_method, 2, INT2FIX(l), buf);
}
else {
ssize_t ss;
@@ -7248,6 +7255,9 @@ copy_stream_fallback_body(VALUE arg)
numwrote = NUM2LONG(n);
stp->total += numwrote;
rest -= numwrote;
+ if (read_method == id_read && RSTRING_LEN(buf) == 0) {
+ break;
+ }
}
return Qnil;