Test/webrick/test_server.rb doesn't finish


#1

e$BIMCO$H$$$$$^$9!#e(B

TestWEBrickServer#test_daemon e$B$,e(B
2/3 e$B$/$i$$$N3NN($G=*$o$j$^$;$s!#e(B

e$B4D6-$Oe(B 2.6.18-6-xen-vserver-amd64 x86_64 GNU/Linux e$B$G!"e(B
Ruby 1.9 e$B$Ne(B r20252 e$B$G3NG’$7$^$7$?!#e(B

forke$B$re(B2e$B2s$9$k$H5/$3$k$_$?$$$G$9!#e(B
e$B<j85$G$O2<5-$N%3!<%I$G;I$5$j$^$9!#e(B

r, w = IO.pipe
Process.fork{
r.close
exit!(0) if fork
w.puts(Process.pid)
sleep
}
Process.kill(:KILL, r.gets.to_i)

fork e$BA0$Ne(B mutex/condvar e$B$N>uBV$,;D$C$F$k$N$,%^%:$$$N$+$J$!$He(B
rb_thread_create_timer_thread e$B$G%9%l%C%I:n$kA0$Ke(B
e$B=i4|2=$9$k%3!<%I$rF~$l$F$_$?$i$J$*$j$^$7$?!#e(B
e$B$3$l$,@5$7$$=hCV$J$N$+$O<+?.$,$"$j$^$;$s!#e(B

Index: thread_pthread.c

— thread_pthread.c (revision 20252)
+++ thread_pthread.c (working copy)
@@ -713,6 +713,8 @@
int err;

    pthread_attr_init(&attr);
  •   pthread_mutex_init(&timer_thread_lock, NULL);
    
  •   pthread_cond_init(&timer_thread_cond, NULL);
    

#ifdef PTHREAD_STACK_MIN
pthread_attr_setstacksize(&attr,
PTHREAD_STACK_MIN + (THREAD_DEBUG ?
BUFSIZ : 0));


#2

e$B$J$+$@$G$9!#e(B

At Wed, 19 Nov 2008 00:31:45 +0900,
shinichiro.h wrote in [ruby-dev:37117]:

fork e$BA0$Ne(B mutex/condvar e$B$N>uBV$,;D$C$F$k$N$,%^%:$$$N$+$J$!$He(B
rb_thread_create_timer_thread e$B$G%9%l%C%I:n$kA0$Ke(B
e$B=i4|2=$9$k%3!<%I$rF~$l$F$_$?$i$J$*$j$^$7$?!#e(B
e$B$3$l$,@5$7$$=hCV$J$N$+$O<+?.$,$"$j$^$;$s!#e(B

mutexe$B$de(Bcondvare$B$,%m%C%/$5$l$?$^$^$@$H$J$K$+%j%=!<%9$rDO$s$@$^$^$Ke(B
e$B$J$k2DG=@-$,$J$$$H$b8@$$@Z$l$J$$$N$G!"e(Bforke$B$NA0$K%?%$%^!<$r;_$a$Fe(B
e$B$*$/$[$&$,0BA4$+$b$7$l$^$;$s!#e(B

e$B<j85$N4D6-$G$O:F8=$7$J$$$h$&$J$N$G3NG’$G$-$J$$$N$G$9$,!"0J2<$N%Q%Ce(B
e$B%A$G$O$I$&$G$7$g$&$+!#e(B

Index: process.c

— process.c (revision 20246)
+++ process.c (working copy)
@@ -976,4 +976,6 @@ void rb_thread_reset_timer_thread(void);
#define after_exec()
(rb_thread_start_timer_thread(), rb_disable_interrupt())
+#define before_fork() before_exec()
+#define after_fork() after_exec()

#include “dln.h”
@@ -2273,5 +2275,6 @@ rb_fork(int *status, int (chfunc)(void
}
#endif

  • for (; (pid = fork()) < 0; prefork()) {
  • for (; before_fork(), (pid = fork()) < 0; prefork()) {
  • after_fork();
    switch (errno) {
    case EAGAIN:
    @@ -2299,5 +2302,4 @@ rb_fork(int *status, int (chfunc)(void
    }
    if (!pid) {
  • rb_thread_reset_timer_thread();
    if (chfunc) {
    #ifdef FD_CLOEXEC
    @@ -2315,8 +2317,8 @@ rb_fork(int *status, int (chfunc)(void
    #endif
    }
  • rb_thread_start_timer_thread();
    }
  • after_fork();
    #ifdef FD_CLOEXEC
  • else if (chfunc) {
  • if (pid && chfunc) {
    close(ep[1]);
    if ((state = read(ep[0], &err, sizeof(err))) < 0) {

#3

e$BIMCO$G$9!#e(B

mutexe$B$de(Bcondvare$B$,%m%C%/$5$l$?$^$^$@$H$J$K$+%j%=!<%9$rDO$s$@$^$^$Ke(B
e$B$J$k2DG=@-$,$J$$$H$b8@$$@Z$l$J$$$N$G!"e(Bforke$B$NA0$K%?%$%^!<$r;_$a$Fe(B
e$B$*$/$[$&$,0BA4$+$b$7$l$^$;$s!#e(B

e$B$J$k$[$I!#$"$-$i$+$K$=$NJ}$,NI$5$=$&$G$9$M!#e(B

e$B<j85$N4D6-$G$O:F8=$7$J$$$h$&$J$N$G3NG’$G$-$J$$$N$G$9$,!"0J2<$N%Q%Ce(B
e$B%A$G$O$I$&$G$7$g$&$+!#e(B

e$B<+J,$NJQ99$r>C$7$F%Q%C%A$rEv$F$F;n$7$F$$^$7$?$,!"e(B
e$B<j85$G$O$=$N%Q%C%A$G;
$^$i$J$/$J$C$F$k$h$&$K;W$$$^$9!#e(B
e$B$"$j$,$H$&$4$6$$$^$7$?!#e(B


#4

e$BIMCO$G$9!#e(B

e$B$"!"M}M3$O$Q$C$H8+$h$/$o$+$i$J$$$N$G$9$,!"e(B
e$B$=$N%Q%C%A$rEv$F$k$He(B TestIO#test_read_error e$B$,e(B
e$B;_$^$i$J$/$J$C$?$h$&$K;W$$$^$9!#e(B

e$B$$=$i$/e(B after_fork e$B$N$"$H$K:n$C$?e(B timer thread e$B$,e(B
e$B$9$0=
$o$C$A$c$C$F$k$+$i$$?$$$G$9!#e(B
e$B$J$+$@$5$s$N%Q%C%A%W%i%92<5-$
$?$$$J$N$G$I$&$G$7$g$&$+!#e(B
e$B<j85$G$O$H$j$"$($:e(B test-all e$B$Oe(B test_delegate
e$B0J30$ODL$C$F$^$9!#e(B

Index: thread.c

— thread.c (revision 20287)
+++ thread.c (working copy)
@@ -2371,6 +2371,7 @@
void
rb_thread_start_timer_thread(void)
{

  • system_working = 1;
    rb_thread_create_timer_thread();
    }

#5

e$BIMCO$G$9!#e(B

e$B<+J,$NJQ99$r>C$7$F%Q%C%A$rEv$F$F;n$7$F$$^$7$?$,!"e(B
e$B<j85$G$O$=$N%Q%C%A$G;
$^$i$J$/$J$C$F$k$h$&$K;W$$$^$9!#e(B
e$B$"$j$,$H$&$4$6$$$^$7$?!#e(B

e$B$"!"M}M3$O$Q$C$H8+$h$/$o$+$i$J$$$N$G$9$,!"e(B
e$B$=$N%Q%C%A$rEv$F$k$He(B TestIO#test_read_error e$B$,e(B
e$B;_$^$i$J$/$J$C$?$h$&$K;W$$$^$9!#e(B