Skip to content

Commit

Permalink
* eval.c (catch_timer): check rb_thread_crtical in main native
Browse files Browse the repository at this point in the history
  thread.

* eval.c (thread_timer): just sends signals periodically, to
  prevent main native thread from receiving them in critical
  section.  [ruby-core:01959]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Dec 15, 2003
1 parent 5fd915f commit ee72d97
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 33 deletions.
9 changes: 9 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
Tue Dec 16 01:14:44 2003 Nobuyoshi Nakada <[email protected]>

* eval.c (catch_timer): check rb_thread_crtical in main native
thread.

* eval.c (thread_timer): just sends signals periodically, to
prevent main native thread from receiving them in critical
section. [ruby-core:01959]

Mon Dec 15 13:32:22 2003 Nobuyoshi Nakada <[email protected]>

* dir.c (check_dirname): check string safety and remove extraneous
Expand Down
50 changes: 17 additions & 33 deletions eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -9498,37 +9498,36 @@ static int thread_init = 0;
# define ruby_signal(x,y) signal((x), (y))
#endif

#if defined(PTHREAD_TIMER)
static pthread_t time_thread;

#if defined(PTHREAD_TIMER) || defined(HAVE_SETITIMER)
static void
catch_timer(sig)
int sig;
{
#if !defined(POSIX_SIGNAL) && !defined(BSD_SIGNAL)
signal(sig, catch_timer);
#endif
rb_thread_schedule();
if (!rb_thread_critical) {
if (rb_trap_immediate) {
rb_thread_schedule();
}
else rb_thread_pending = 1;
}
}

#ifdef PTHREAD_TIMER
static pthread_t time_thread;

static void*
thread_timer(dummy)
void *dummy;
{
struct timespec req, rem;

for (;;) {
if (!rb_thread_critical) {
if (rb_trap_immediate) {
pthread_kill(ruby_thid, SIGVTALRM);
}
else {
rb_thread_pending = 1;
}
req.tv_sec = 0;
req.tv_nsec = 10000000;
nanosleep(&req, &rem);
}
req.tv_sec = 0;
req.tv_nsec = 10000000;
nanosleep(&req, &rem);
pthread_kill(ruby_thid, SIGVTALRM);
}
}

Expand All @@ -9541,23 +9540,7 @@ void
rb_thread_stop_timer()
{
}
#elif defined(HAVE_SETITIMER)

static void
catch_timer(sig)
int sig;
{
#if !defined(POSIX_SIGNAL) && !defined(BSD_SIGNAL)
signal(sig, catch_timer);
#endif
if (!rb_thread_critical) {
if (rb_trap_immediate) {
rb_thread_schedule();
}
else rb_thread_pending = 1;
}
}

#else /* HAVE_SETITIMER */
void
rb_thread_start_timer()
{
Expand All @@ -9581,7 +9564,8 @@ rb_thread_stop_timer()
tval.it_value = tval.it_interval;
setitimer(ITIMER_VIRTUAL, &tval, NULL);
}
#else
#endif
#else /* !(PTHREAD_TIMER || HAVE_SETITIMER) */
int rb_thread_tick = THREAD_TICK;
#endif

Expand Down

0 comments on commit ee72d97

Please sign in to comment.