ruby-changes:36395
From: akr <ko1@a...>
Date: Tue, 18 Nov 2014 18:11:21 +0900 (JST)
Subject: [ruby-changes:36395] akr:r48476 (trunk): * include/ruby/io.h (FMODE_WSPLIT): Removed. The write() system call
akr 2014-11-18 18:10:59 +0900 (Tue, 18 Nov 2014) New Revision: 48476 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48476 Log: * 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. Modified files: trunk/ChangeLog trunk/include/ruby/io.h trunk/io.c Index: include/ruby/io.h =================================================================== --- include/ruby/io.h (revision 48475) +++ include/ruby/io.h (revision 48476) @@ -109,8 +109,6 @@ typedef struct rb_io_t { https://github.com/ruby/ruby/blob/trunk/include/ruby/io.h#L109 #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 */ Index: ChangeLog =================================================================== --- ChangeLog (revision 48475) +++ ChangeLog (revision 48476) @@ -1,3 +1,15 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue Nov 18 18:06:43 2014 Tanaka Akira <akr@f...> + + * 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@r...> * object.c (check_setter_id): show the original argument instead Index: io.c =================================================================== --- io.c (revision 48475) +++ io.c (revision 48476) @@ -909,29 +909,6 @@ io_alloc(VALUE klass) https://github.com/ruby/ruby/blob/trunk/io.c#L909 # 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 https://github.com/ruby/ruby/blob/trunk/io.c#L1006 } #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) https://github.com/ruby/ruby/blob/trunk/io.c#L1257 } } 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) https://github.com/ruby/ruby/blob/trunk/io.c#L1291 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) https://github.com/ruby/ruby/blob/trunk/io.c#L9216 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); } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/