diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | file.c | 6 |
2 files changed, 9 insertions, 2 deletions
@@ -1,3 +1,8 @@ +Thu Feb 28 11:43:56 2008 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * file.c (rb_file_flock): immediately returns on EAGAIN if + non-blocking. [ruby-core:15672] + Thu Feb 28 11:23:50 2008 Nobuyoshi Nakada <nobu@ruby-lang.org> * io.c (rb_io_getline_1): get rid of segfault. [ruby-dev:33938] @@ -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); } |