summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-02-28 02:43:59 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-02-28 02:43:59 +0000
commit5848032ce5784083e230c608b3b63d9072fa40f8 (patch)
tree3330d6cec8b4d6c90eedc1e07833d64f97f12322
parent586f727b8c37630d36618f8f09765b92098af8a0 (diff)
* 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
-rw-r--r--ChangeLog5
-rw-r--r--file.c6
2 files changed, 9 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 2478f3e..55ef99c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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]
diff --git a/file.c b/file.c
index 3a2555d..e7089d8 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);
}