summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog12
-rw-r--r--include/ruby/io.h2
-rw-r--r--io.c52
3 files changed, 15 insertions, 51 deletions
diff --git a/ChangeLog b/ChangeLog
index 7574523a47..c9927ce2c9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+Tue Nov 18 18:06:43 2014 Tanaka Akira <akr@fsij.org>
+
+ * 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.
+
Tue Nov 18 03:23:06 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
* object.c (check_setter_id): show the original argument instead
diff --git a/include/ruby/io.h b/include/ruby/io.h
index 488a092004..048090c27a 100644
--- a/include/ruby/io.h
+++ b/include/ruby/io.h
@@ -109,8 +109,6 @@ typedef struct rb_io_t {
#define FMODE_APPEND 0x00000040
#define FMODE_CREATE 0x00000080
/* #define FMODE_NOREVLOOKUP 0x00000100 */
-#define FMODE_WSPLIT 0x00000200
-#define FMODE_WSPLIT_INITIALIZED 0x00000400
#define FMODE_TRUNC 0x00000800
#define FMODE_TEXTMODE 0x00001000
/* #define FMODE_PREP 0x00010000 */
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);
}