From d2d7e237f763852ac824dbb8cf4340ccdf1b7d90 Mon Sep 17 00:00:00 2001 From: akr Date: Mon, 22 May 2006 22:12:57 +0000 Subject: avoid useless fcntl in rb_io_set_nonblock. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@10180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- io.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/io.c b/io.c index 22257b65a..83c51f443 100644 --- a/io.c +++ b/io.c @@ -1247,9 +1247,11 @@ void rb_io_set_nonblock(OpenFile *fptr) #else flags = 0; #endif - flags |= O_NONBLOCK; - if (fcntl(fptr->fd, F_SETFL, flags) == -1) { - rb_sys_fail(fptr->path); + if ((flags & O_NONBLOCK) == 0) { + flags |= O_NONBLOCK; + if (fcntl(fptr->fd, F_SETFL, flags) == -1) { + rb_sys_fail(fptr->path); + } } } -- cgit