# Test/webrick/test\_server.rb doesn't finish

**URL:** <https://www.ruby-forum.com/t/test-webrick-test-server-rb-doesnt-finish/153547>\
**Category:** Development\
**Created:** [November 18, 2008, 4:36pm UTC](https://www.ruby-forum.com/t/test-webrick-test-server-rb-doesnt-finish/153547 "2008-11-18T16:36:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![shinichiro.h](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/34f0e0/32.png) [@shinichiro.h](https://www.ruby-forum.com/u/shinichiro.h)\
**Post date:** [November 18, 2008, 4:36pm UTC](https://www.ruby-forum.com/t/test-webrick-test-server-rb-doesnt-finish/153547/1 "2008-11-18T16:36:21Z")

</div>

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));

---

<div class="post-metadata">

**Author:** ![shinichiro.h](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/34f0e0/32.png) [@shinichiro.h](https://www.ruby-forum.com/u/shinichiro.h)\
**Post date:** [November 18, 2008, 7:00pm UTC](https://www.ruby-forum.com/t/test-webrick-test-server-rb-doesnt-finish/153547/2 "2008-11-18T19:00:55Z")

</div>

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) {

---

<div class="post-metadata">

**Author:** ![shinichiro.h](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/34f0e0/32.png) [@shinichiro.h](https://www.ruby-forum.com/u/shinichiro.h)\
**Post date:** [November 18, 2008, 7:25pm UTC](https://www.ruby-forum.com/t/test-webrick-test-server-rb-doesnt-finish/153547/3 "2008-11-18T19:25:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![shinichiro.h](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/34f0e0/32.png) [@shinichiro.h](https://www.ruby-forum.com/u/shinichiro.h)\
**Post date:** [November 19, 2008, 6:44pm UTC](https://www.ruby-forum.com/t/test-webrick-test-server-rb-doesnt-finish/153547/4 "2008-11-19T18:44:28Z")

</div>

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();  
}

---

<div class="post-metadata">

**Author:** ![shinichiro.h](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/34f0e0/32.png) [@shinichiro.h](https://www.ruby-forum.com/u/shinichiro.h)\
**Post date:** [November 18, 2008, 7:36pm UTC](https://www.ruby-forum.com/t/test-webrick-test-server-rb-doesnt-finish/153547/5 "2008-11-18T19:36:44Z")

</div>

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
