Project

General

Profile

Bug #5240 » rb-th.diff

View differences:

ruby1.9.1-1.9.3~preview1+svn33077/thread_pthread.c
static int timer_thread_pipe[2] = {-1, -1};
static int timer_thread_pipe_owner_process;
#if 0
static inline int
timer_thread_running() {
return timer_thread_pipe_owner_process == getpid() ? 1 : 0;
}
static inline void timer_thread_set() {
timer_thread_pipe_owner_process = getpid();
}
void timer_thread_child_at_fork() {
}
#else
static inline int
timer_thread_running() {
return timer_thread_pipe_owner_process;
}
static inline void timer_thread_set() {
timer_thread_pipe_owner_process = 1;
}
void timer_thread_child_at_fork() {
timer_thread_pipe_owner_process = 0;
}
#endif
#define TT_DEBUG 0
#define WRITE_CONST(fd, str) (void)(write((fd),(str),sizeof(str)-1)<0)
......
ssize_t result;
/* already opened */
if (timer_thread_pipe_owner_process == getpid()) {
if (timer_thread_running()) {
const char *buff = "!";
retry:
if ((result = write(timer_thread_pipe[1], buff, 1)) <= 0) {
......
#endif
/* communication pipe with timer thread and signal handler */
if (timer_thread_pipe_owner_process != getpid()) {
if (!timer_thread_running()) {
if (timer_thread_pipe[0] != -1) {
/* close pipe of parent process */
close_communication_pipe();
......
#endif /* defined(HAVE_FCNTL) && defined(F_GETFL) && defined(F_SETFL) */
/* validate pipe on this process */
timer_thread_pipe_owner_process = getpid();
timer_thread_set();
}
/* create timer thread */
(1-1/2)