diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-02-28 02:43:59 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-02-28 02:43:59 +0000 |
commit | 5848032ce5784083e230c608b3b63d9072fa40f8 (patch) | |
tree | 3330d6cec8b4d6c90eedc1e07833d64f97f12322 /file.c | |
parent | 586f727b8c37630d36618f8f09765b92098af8a0 (diff) | |
download | ruby-5848032ce5784083e230c608b3b63d9072fa40f8.tar.gz |
* file.c (rb_file_flock): immediately returns on EAGAIN if
non-blocking. [ruby-core:15672]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15624 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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); } |