aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-18 09:10:59 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-18 09:10:59 +0000
commit8463a90871adaf82a31e598943ae3762a5a666aa (patch)
tree0c4675cf71a6df0b2abde962e91544ac9889d75e /io.c
parentb3eaacdefcb8ba8626f8a77caf079e39b90402fc (diff)
downloadruby-8463a90871adaf82a31e598943ae3762a5a666aa.tar.gz
* include/ruby/io.h (FMODE_WSPLIT): Removed. The write() system call
is not required to split. It was useful to avoid whole process blocking in Ruby 1.8 but not useful since write() is invoked without GVL. (FMODE_WSPLIT_INITIALIZED): Ditto. * io.c (wsplit_p): Removed. (io_writable_length): Removed. (rb_fcntl): Don't update the removed flags. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48476 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c52
1 files changed, 3 insertions, 49 deletions
diff --git a/io.c b/io.c
index a5173a1d95..8c14b7b9b0 100644
--- a/io.c
+++ b/io.c
@@ -909,29 +909,6 @@ io_alloc(VALUE klass)
# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#endif
-static int
-wsplit_p(rb_io_t *fptr)
-{
-#if defined(HAVE_FCNTL) && defined(F_GETFL) && defined(O_NONBLOCK)
- int r;
-#endif
-
- if (!(fptr->mode & FMODE_WSPLIT_INITIALIZED)) {
- struct stat buf;
- if (fstat(fptr->fd, &buf) == 0 &&
- !S_ISREG(buf.st_mode)
-#if defined(HAVE_FCNTL) && defined(F_GETFL) && defined(O_NONBLOCK)
- && (r = fcntl(fptr->fd, F_GETFL)) != -1 &&
- !(r & O_NONBLOCK)
-#endif
- ) {
- fptr->mode |= FMODE_WSPLIT;
- }
- fptr->mode |= FMODE_WSPLIT_INITIALIZED;
- }
- return fptr->mode & FMODE_WSPLIT;
-}
-
struct io_internal_read_struct {
int fd;
void *buf;
@@ -1029,22 +1006,11 @@ rb_writev_internal(int fd, const struct iovec *iov, int iovcnt)
}
#endif
-static long
-io_writable_length(rb_io_t *fptr, long l)
-{
- if (PIPE_BUF < l &&
- !rb_thread_alone() &&
- wsplit_p(fptr)) {
- l = PIPE_BUF;
- }
- return l;
-}
-
static VALUE
io_flush_buffer_sync(void *arg)
{
rb_io_t *fptr = arg;
- long l = io_writable_length(fptr, fptr->wbuf.len);
+ long l = fptr->wbuf.len;
ssize_t r = write(fptr->fd, fptr->wbuf.ptr+fptr->wbuf.off, (size_t)l);
if (fptr->wbuf.len <= r) {
@@ -1291,8 +1257,7 @@ io_binwrite_string(VALUE arg)
}
}
else {
- long l = io_writable_length(fptr, p->length);
- r = rb_write_internal(fptr->fd, p->ptr, l);
+ r = rb_write_internal(fptr->fd, p->ptr, p->length);
}
return r;
@@ -1326,8 +1291,7 @@ io_binwrite_string(VALUE arg)
if (fptr->stdio_file != stderr && !rb_thread_fd_writable(fptr->fd))
rb_io_check_closed(fptr);
- l = io_writable_length(p->fptr, p->length);
- return rb_write_internal(p->fptr->fd, p->ptr, l);
+ return rb_write_internal(p->fptr->fd, p->ptr, p->length);
}
#endif
@@ -9252,16 +9216,6 @@ rb_fcntl(VALUE io, VALUE req, VALUE arg)
RSTRING_PTR(arg)[RSTRING_LEN(arg)-1] = '\0';
}
- if (cmd == F_SETFL) {
- if (narg & O_NONBLOCK) {
- fptr->mode |= FMODE_WSPLIT_INITIALIZED;
- fptr->mode &= ~FMODE_WSPLIT;
- }
- else {
- fptr->mode &= ~(FMODE_WSPLIT_INITIALIZED|FMODE_WSPLIT);
- }
- }
-
return INT2NUM(retval);
}