1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
nobu 2008-02-28 02:43:59 +00:00
parent 586f727b8c
commit 5848032ce5
2 changed files with 9 additions and 2 deletions

View file

@ -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> 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] * io.c (rb_io_getline_1): get rid of segfault. [ruby-dev:33938]

6
file.c
View file

@ -3256,10 +3256,10 @@ rb_file_flock(VALUE obj, VALUE operation)
{ {
#ifndef __CHECKER__ #ifndef __CHECKER__
rb_io_t *fptr; rb_io_t *fptr;
int op[2]; int op[2], op1;
rb_secure(2); rb_secure(2);
op[1] = NUM2INT(operation); op[1] = op1 = NUM2INT(operation);
GetOpenFile(obj, fptr); GetOpenFile(obj, fptr);
op[0] = fptr->fd; op[0] = fptr->fd;
@ -3273,6 +3273,7 @@ rb_file_flock(VALUE obj, VALUE operation)
#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN #if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
case EWOULDBLOCK: case EWOULDBLOCK:
#endif #endif
if (op1 & LOCK_NB) goto exit;
rb_thread_polling(); rb_thread_polling();
rb_io_check_closed(fptr); rb_io_check_closed(fptr);
continue; continue;
@ -3287,6 +3288,7 @@ rb_file_flock(VALUE obj, VALUE operation)
rb_sys_fail(fptr->path); rb_sys_fail(fptr->path);
} }
} }
exit:
#endif #endif
return INT2FIX(0); return INT2FIX(0);
} }