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

* ext/io/nonblock/nonblock.c (io_nonblock_set): Avoid F_SETFL if

we're not changing the O_NONBLOCK bit. F_SETFL is an expensive
  operation since it needs to affect all processes with the same
  file object.
  The patch is written by Eric Wong. [ruby-core:35556]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kosaki 2011-04-04 13:11:14 +00:00
parent 3ba502d5f0
commit 78ea7afe97
2 changed files with 16 additions and 2 deletions

View file

@ -1,3 +1,11 @@
Mon Apr 4 22:02:16 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
* ext/io/nonblock/nonblock.c (io_nonblock_set): Avoid F_SETFL if
we're not changing the O_NONBLOCK bit. F_SETFL is an expensive
operation since it needs to affect all processes with the same
file object.
The patch is written by Eric Wong. [ruby-core:35556]
Mon Apr 4 21:41:26 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
* io.c (rb_io_syswrite): While local FS writes are usually

View file

@ -47,10 +47,16 @@ rb_io_nonblock_p(VALUE io)
static void
io_nonblock_set(int fd, int f, int nb)
{
if (nb)
if (nb) {
if ((f & O_NONBLOCK) != 0)
return;
f |= O_NONBLOCK;
else
}
else {
if ((f & O_NONBLOCK) == 0)
return;
f &= ~O_NONBLOCK;
}
if (fcntl(fd, F_SETFL, f) == -1)
rb_sys_fail(0);
}