diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-05-22 22:12:57 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-05-22 22:12:57 +0000 |
commit | c4ab77fb3b1fb6beb0b1f3eb480b3a921e091420 (patch) | |
tree | eb68724fc0e356f3aea1c3b77df20fbfe892e895 /io.c | |
parent | 613bc2efc0d67d186f3445fdf927a7691c405ed7 (diff) |
avoid useless fcntl in rb_io_set_nonblock.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -1196,9 +1196,11 @@ void rb_io_set_nonblock(OpenFile *fptr) #else flags = 0; #endif - flags |= O_NONBLOCK; - if (fcntl(fileno(fptr->f), F_SETFL, flags) == -1) { - rb_sys_fail(fptr->path); + if ((flags & O_NONBLOCK) == 0) { + flags |= O_NONBLOCK; + if (fcntl(fileno(fptr->f), F_SETFL, flags) == -1) { + rb_sys_fail(fptr->path); + } } if (fptr->f2) { #ifdef F_GETFL @@ -1209,9 +1211,11 @@ void rb_io_set_nonblock(OpenFile *fptr) #else flags = 0; #endif - flags |= O_NONBLOCK; - if (fcntl(fileno(fptr->f2), F_SETFL, flags) == -1) { - rb_sys_fail(fptr->path); + if ((flags & O_NONBLOCK) == 0) { + flags |= O_NONBLOCK; + if (fcntl(fileno(fptr->f2), F_SETFL, flags) == -1) { + rb_sys_fail(fptr->path); + } } } } |