From 992f9678f7be29a9bbe2e7a57479859c283a6239 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 28 Feb 2008 02:43:59 +0000 Subject: * file.c (rb_file_flock): immediately returns on EAGAIN if non-blocking. [ruby-core:15672] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@15624 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- file.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'file.c') diff --git a/file.c b/file.c index 3a2555d21..e7089d88a 100644 --- a/file.c +++ b/file.c @@ -3256,10 +3256,10 @@ rb_file_flock(VALUE obj, VALUE operation) { #ifndef __CHECKER__ rb_io_t *fptr; - int op[2]; + int op[2], op1; rb_secure(2); - op[1] = NUM2INT(operation); + op[1] = op1 = NUM2INT(operation); GetOpenFile(obj, fptr); op[0] = fptr->fd; @@ -3273,6 +3273,7 @@ rb_file_flock(VALUE obj, VALUE operation) #if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN case EWOULDBLOCK: #endif + if (op1 & LOCK_NB) goto exit; rb_thread_polling(); rb_io_check_closed(fptr); continue; @@ -3287,6 +3288,7 @@ rb_file_flock(VALUE obj, VALUE operation) rb_sys_fail(fptr->path); } } + exit: #endif return INT2FIX(0); } -- cgit