1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
akr 2014-11-18 09:10:59 +00:00
parent b3eaacdefc
commit 8463a90871
3 changed files with 15 additions and 51 deletions

View file

@ -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

View file

@ -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 */

52
io.c
View file

@ -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);
}