summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-14 18:08:40 +0000
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-14 18:08:40 +0000
commita24f2d99155e20833f26d9bbc1d97bb0ae31a9c4 (patch)
treeb5ab0e4494c2d606028660afd717f170a6fc2dff /file.c
parent2d2cac4b05e6bc24e1d1a40b9d1a972732fe4fc9 (diff)
* file.c (rb_file_flock): use rb_thread_wait_for() instead of
rb_thread_polling(). When getting EAGAIN, we need to wait a while even if no multi threading. * thread.c (sleep_for_polling, rb_thread_polling) removed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38382 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/file.c b/file.c
index 2aa896ae47..08cd5f8dcf 100644
--- a/file.c
+++ b/file.c
@@ -4200,6 +4200,7 @@ rb_file_flock(VALUE obj, VALUE operation)
{
rb_io_t *fptr;
int op[2], op1;
+ struct timeval time;
rb_secure(2);
op[1] = op1 = NUM2INT(operation);
@@ -4217,7 +4218,10 @@ rb_file_flock(VALUE obj, VALUE operation)
case EWOULDBLOCK:
#endif
if (op1 & LOCK_NB) return Qfalse;
- rb_thread_polling();
+
+ time.tv_sec = 0;
+ time.tv_usec = 100 * 1000; /* 0.1 sec */
+ rb_thread_wait_for(time);
rb_io_check_closed(fptr);
continue;