* thread_pthread.c (timer_thread_sleep): use poll() instead of
select(). select doesn't work if timer_thread_pipe[0] is greater than FD_SETSIZE. * thread_pthread.c (USE_SLEEPY_TIMER_THREAD): add a dependency against poll. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39681 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3887a34c90
commit
27f25728e6
@ -1,3 +1,11 @@
|
|||||||
|
Wed Mar 6 21:31:35 2013 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||||
|
|
||||||
|
* thread_pthread.c (timer_thread_sleep): use poll() instead of
|
||||||
|
select(). select doesn't work if timer_thread_pipe[0] is
|
||||||
|
greater than FD_SETSIZE.
|
||||||
|
* thread_pthread.c (USE_SLEEPY_TIMER_THREAD): add a dependency
|
||||||
|
against poll.
|
||||||
|
|
||||||
Wed Mar 6 21:00:23 2013 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
Wed Mar 6 21:00:23 2013 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||||
|
|
||||||
* thread_pthread.c (USE_SLEEPY_TIMER_THREAD): use more accurate
|
* thread_pthread.c (USE_SLEEPY_TIMER_THREAD): use more accurate
|
||||||
|
@ -30,6 +30,9 @@
|
|||||||
#if defined(__native_client__) && defined(NACL_NEWLIB)
|
#if defined(__native_client__) && defined(NACL_NEWLIB)
|
||||||
# include "nacl/select.h"
|
# include "nacl/select.h"
|
||||||
#endif
|
#endif
|
||||||
|
#if HAVE_POLL
|
||||||
|
#include <poll.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
static void native_mutex_lock(pthread_mutex_t *lock);
|
static void native_mutex_lock(pthread_mutex_t *lock);
|
||||||
static void native_mutex_unlock(pthread_mutex_t *lock);
|
static void native_mutex_unlock(pthread_mutex_t *lock);
|
||||||
@ -53,11 +56,10 @@ static pthread_t timer_thread_id;
|
|||||||
#define USE_MONOTONIC_COND 0
|
#define USE_MONOTONIC_COND 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_FCNTL) && defined(F_GETFL) && defined(F_SETFL) && defined(O_NONBLOCK) && !defined(__native_client__)
|
#if defined(HAVE_POLL) && defined(HAVE_FCNTL) && defined(F_GETFL) && defined(F_SETFL) && defined(O_NONBLOCK) && !defined(__native_client__)
|
||||||
/* The timer thread sleeps while only one Ruby thread is running. */
|
/* The timer thread sleeps while only one Ruby thread is running. */
|
||||||
# define USE_SLEEPY_TIMER_THREAD 1
|
# define USE_SLEEPY_TIMER_THREAD 1
|
||||||
#else
|
#else
|
||||||
/* Doesn't have select(1). */
|
|
||||||
# define USE_SLEEPY_TIMER_THREAD 0
|
# define USE_SLEEPY_TIMER_THREAD 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1218,23 +1220,20 @@ timer_thread_sleep(rb_global_vm_lock_t* gvl)
|
|||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
int need_polling;
|
int need_polling;
|
||||||
struct timeval timeout;
|
struct pollfd pollfd;
|
||||||
fd_set rfds;
|
|
||||||
FD_ZERO(&rfds);
|
pollfd.fd = timer_thread_pipe[0];
|
||||||
FD_SET(timer_thread_pipe[0], &rfds);
|
pollfd.events = POLLIN;
|
||||||
|
|
||||||
need_polling = check_signal_thread_list();
|
need_polling = check_signal_thread_list();
|
||||||
|
|
||||||
if (gvl->waiting > 0 || need_polling) {
|
if (gvl->waiting > 0 || need_polling) {
|
||||||
timeout.tv_sec = 0;
|
|
||||||
timeout.tv_usec = TIME_QUANTUM_USEC;
|
|
||||||
|
|
||||||
/* polling (TIME_QUANTUM_USEC usec) */
|
/* polling (TIME_QUANTUM_USEC usec) */
|
||||||
result = select(timer_thread_pipe[0] + 1, &rfds, 0, 0, &timeout);
|
result = poll(&pollfd, 1, TIME_QUANTUM_USEC/1000);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* wait (infinite) */
|
/* wait (infinite) */
|
||||||
result = select(timer_thread_pipe[0] + 1, &rfds, 0, 0, 0);
|
result = poll(&pollfd, 1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user