mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
2d2cac4b05
commit
a24f2d9915
3 changed files with 12 additions and 20 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
Sat Dec 15 03:06:40 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
Sat Dec 15 00:03:31 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
Sat Dec 15 00:03:31 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||||
|
|
||||||
* signal.c (rb_f_kill): remove rb_thread_polling() because this
|
* signal.c (rb_f_kill): remove rb_thread_polling() because this
|
||||||
|
|
6
file.c
6
file.c
|
@ -4200,6 +4200,7 @@ rb_file_flock(VALUE obj, VALUE operation)
|
||||||
{
|
{
|
||||||
rb_io_t *fptr;
|
rb_io_t *fptr;
|
||||||
int op[2], op1;
|
int op[2], op1;
|
||||||
|
struct timeval time;
|
||||||
|
|
||||||
rb_secure(2);
|
rb_secure(2);
|
||||||
op[1] = op1 = NUM2INT(operation);
|
op[1] = op1 = NUM2INT(operation);
|
||||||
|
@ -4217,7 +4218,10 @@ rb_file_flock(VALUE obj, VALUE operation)
|
||||||
case EWOULDBLOCK:
|
case EWOULDBLOCK:
|
||||||
#endif
|
#endif
|
||||||
if (op1 & LOCK_NB) return Qfalse;
|
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);
|
rb_io_check_closed(fptr);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
19
thread.c
19
thread.c
|
@ -994,15 +994,6 @@ sleep_wait_for_interrupt(rb_thread_t *th, double sleepsec,int spurious_check)
|
||||||
sleep_timeval(th, double2timeval(sleepsec),spurious_check);
|
sleep_timeval(th, double2timeval(sleepsec),spurious_check);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
sleep_for_polling(rb_thread_t *th)
|
|
||||||
{
|
|
||||||
struct timeval time;
|
|
||||||
time.tv_sec = 0;
|
|
||||||
time.tv_usec = 100 * 1000; /* 0.1 sec */
|
|
||||||
sleep_timeval(th, time, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
rb_thread_wait_for(struct timeval time)
|
rb_thread_wait_for(struct timeval time)
|
||||||
{
|
{
|
||||||
|
@ -1010,16 +1001,6 @@ rb_thread_wait_for(struct timeval time)
|
||||||
sleep_timeval(th, time, 1);
|
sleep_timeval(th, time, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
rb_thread_polling(void)
|
|
||||||
{
|
|
||||||
if (!rb_thread_alone()) {
|
|
||||||
rb_thread_t *th = GET_THREAD();
|
|
||||||
RUBY_VM_CHECK_INTS_BLOCKING(th);
|
|
||||||
sleep_for_polling(th);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CAUTION: This function causes thread switching.
|
* CAUTION: This function causes thread switching.
|
||||||
* rb_thread_check_ints() check ruby's interrupts.
|
* rb_thread_check_ints() check ruby's interrupts.
|
||||||
|
|
Loading…
Add table
Reference in a new issue