0001-backport-ruby_1_8-26371.patch
| b/ChangeLog | ||
|---|---|---|
| 1 |
Fri Jan 22 01:22:27 2010 NAKAMURA Usaku <usa@ruby-lang.org> |
|
| 2 | ||
| 3 |
* eval.c (thread_timer, rb_thread_stop_timer): check the timing of |
|
| 4 |
stopping timer. patch from KOSAKI Motohiro <kosaki.motohiro _AT_ |
|
| 5 |
jp.fujitsu.com> |
|
| 6 | ||
| 7 |
* eval.c (rb_thread_start_timer): NetBSD5 seems to be hung when calling |
|
| 8 |
pthread_create() from pthread_atfork()'s parent handler. |
|
| 9 | ||
| 10 |
* io.c (pipe_open): workaround for NetBSD5. stop timer thread before |
|
| 11 |
fork(), and start it if needed. |
|
| 12 | ||
| 13 |
* process.c (rb_f_fork, rb_f_system): ditto. |
|
| 14 |
fixed [ruby-dev:40074] |
|
| 15 | ||
| 1 | 16 |
Sun Jan 10 19:00:31 2010 Nobuyoshi Nakada <nobu@ruby-lang.org> |
| 2 | 17 | |
| 3 | 18 |
* lib/webrick/accesslog.rb : Escape needed. |
| b/eval.c | ||
|---|---|---|
| 12292 | 12292 |
pthread_t thread; |
| 12293 | 12293 |
} time_thread = {PTHREAD_COND_INITIALIZER, PTHREAD_MUTEX_INITIALIZER};
|
| 12294 | 12294 | |
| 12295 |
static int timer_stopping; |
|
| 12296 | ||
| 12295 | 12297 |
#define safe_mutex_lock(lock) \ |
| 12296 | 12298 |
pthread_mutex_lock(lock); \ |
| 12297 | 12299 |
pthread_cleanup_push((void (*)_((void *)))pthread_mutex_unlock, lock) |
| ... | ... | |
| 12316 | 12318 |
#define WAIT_FOR_10MS() \ |
| 12317 | 12319 |
pthread_cond_timedwait(&running->cond, &running->lock, get_ts(&to, PER_NANO/100)) |
| 12318 | 12320 |
while ((err = WAIT_FOR_10MS()) == EINTR || err == ETIMEDOUT) {
|
| 12321 |
if (timer_stopping) |
|
| 12322 |
break; |
|
| 12323 | ||
| 12319 | 12324 |
if (!rb_thread_critical) {
|
| 12320 | 12325 |
rb_thread_pending = 1; |
| 12321 | 12326 |
if (rb_trap_immediate) {
|
| ... | ... | |
| 12343 | 12348 |
safe_mutex_lock(&time_thread.lock); |
| 12344 | 12349 |
if (pthread_create(&time_thread.thread, 0, thread_timer, args) == 0) {
|
| 12345 | 12350 |
thread_init = 1; |
| 12351 |
#ifndef __NetBSD__ |
|
| 12346 | 12352 |
pthread_atfork(0, 0, rb_thread_stop_timer); |
| 12353 |
#endif |
|
| 12347 | 12354 |
pthread_cond_wait(&start, &time_thread.lock); |
| 12348 | 12355 |
} |
| 12349 | 12356 |
pthread_cleanup_pop(1); |
| ... | ... | |
| 12354 | 12361 |
{
|
| 12355 | 12362 |
if (!thread_init) return; |
| 12356 | 12363 |
safe_mutex_lock(&time_thread.lock); |
| 12364 |
timer_stopping = 1; |
|
| 12357 | 12365 |
pthread_cond_signal(&time_thread.cond); |
| 12358 | 12366 |
thread_init = 0; |
| 12359 | 12367 |
pthread_cleanup_pop(1); |
| 12360 | 12368 |
pthread_join(time_thread.thread, NULL); |
| 12369 |
timer_stopping = 0; |
|
| 12361 | 12370 |
} |
| 12362 | 12371 |
#elif defined(HAVE_SETITIMER) |
| 12363 | 12372 |
static void |
| b/io.c | ||
|---|---|---|
| 3245 | 3245 |
} |
| 3246 | 3246 | |
| 3247 | 3247 |
retry: |
| 3248 |
#ifdef __NetBSD__ |
|
| 3249 |
rb_thread_stop_timer(); |
|
| 3250 |
#endif |
|
| 3248 | 3251 |
switch ((pid = fork())) {
|
| 3249 | 3252 |
case 0: /* child */ |
| 3250 | 3253 |
if (modef & FMODE_READABLE) {
|
| ... | ... | |
| 3272 | 3275 |
ruby_sourcefile, ruby_sourceline, pname); |
| 3273 | 3276 |
_exit(127); |
| 3274 | 3277 |
} |
| 3278 |
#ifdef __NetBSD__ |
|
| 3279 |
rb_thread_start_timer(); |
|
| 3280 |
#endif |
|
| 3275 | 3281 |
rb_io_synchronized(RFILE(orig_stdout)->fptr); |
| 3276 | 3282 |
rb_io_synchronized(RFILE(orig_stderr)->fptr); |
| 3277 | 3283 |
return Qnil; |
| 3278 | 3284 | |
| 3279 | 3285 |
case -1: /* fork failed */ |
| 3286 |
#ifdef __NetBSD__ |
|
| 3287 |
rb_thread_start_timer(); |
|
| 3288 |
#endif |
|
| 3280 | 3289 |
if (errno == EAGAIN) {
|
| 3281 | 3290 |
rb_thread_sleep(1); |
| 3282 | 3291 |
goto retry; |
| ... | ... | |
| 3297 | 3306 |
break; |
| 3298 | 3307 | |
| 3299 | 3308 |
default: /* parent */ |
| 3309 |
#ifdef __NetBSD__ |
|
| 3310 |
rb_thread_start_timer(); |
|
| 3311 |
#endif |
|
| 3300 | 3312 |
if (pid < 0) rb_sys_fail(pname); |
| 3301 | 3313 |
else {
|
| 3302 | 3314 |
VALUE port = io_alloc(rb_cIO); |
| b/process.c | ||
|---|---|---|
| 1330 | 1330 |
fflush(stderr); |
| 1331 | 1331 |
#endif |
| 1332 | 1332 | |
| 1333 |
#ifdef __NetBSD__ |
|
| 1334 |
before_exec(); |
|
| 1335 |
pid = fork(); |
|
| 1336 |
after_exec(); |
|
| 1337 |
switch (pid) {
|
|
| 1338 |
#else |
|
| 1333 | 1339 |
switch (pid = fork()) {
|
| 1340 |
#endif |
|
| 1334 | 1341 |
case 0: |
| 1335 | 1342 |
#ifdef linux |
| 1336 | 1343 |
after_exec(); |
| ... | ... | |
| 1570 | 1577 | |
| 1571 | 1578 |
chfunc = signal(SIGCHLD, SIG_DFL); |
| 1572 | 1579 |
retry: |
| 1580 |
#ifdef __NetBSD__ |
|
| 1581 |
before_exec(); |
|
| 1582 |
#endif |
|
| 1573 | 1583 |
pid = fork(); |
| 1574 | 1584 |
if (pid == 0) {
|
| 1575 | 1585 |
/* child process */ |
| ... | ... | |
| 1577 | 1587 |
rb_protect(proc_exec_args, (VALUE)&earg, NULL); |
| 1578 | 1588 |
_exit(127); |
| 1579 | 1589 |
} |
| 1590 |
#ifdef __NetBSD__ |
|
| 1591 |
after_exec(); |
|
| 1592 |
#endif |
|
| 1580 | 1593 |
if (pid < 0) {
|
| 1581 | 1594 |
if (errno == EAGAIN) {
|
| 1582 | 1595 |
rb_thread_sleep(1); |
| 1583 |
- |
|