You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Jason Greene <us...@tds.net> on 2000/11/29 19:48:05 UTC

solaris + libthread + keepalive fix

Apache compiled on solaris 2.6,2.7,2.8 with any module that loads libthread will cause SIGALRM to break.
I ran into this problem using chilisoft's module which loads libthread.This of course will also occur if you use
PTHREAD_SERIALIZATION.

Description of problem:
Solaris + Apache 1.3.X + libthread will cause KeepAlive Timeouts
 to break, which causes apache to leak children until MaxClients
 is hit or system runs out of RAM.

 How to reproduce:
1.. Set MaxClients to 1, which will allow only one child
2. telnet host 80
   GET / HTTP/1.1
    Host: blah
    <hit enter>
    <apache will send response>
    <apache will send 0>
    <apache will wait for input>
 4. HTTP 1.1 protocol will by default enable KeepAlive, which
    will keep the connection open, wait 15 seconds(apache default)
    and the connection will close
 5. repeat once more, second time apache will never disconnect you

 The main apache daemon sends SIGALRM to the child process to inform
it that it has timed out. If you truss the child process, you will see
 it not catch SIGALRM

It appears that Apache relies on sigsetjmp and siglongjmp to clear the alarm event.
This, of course, doesn't work when there is multiple threads on Solaris

According to SUN documentation, (and Solaris Source) sigprocmask will
 call pthread_sigprocmask in a threaded environment. This solves the problem
and allows signal catching to work in a threaded, and non-threaded
environemnt

I have attached an example patch that I sent chilisoft, but I'm sure it will need to be modified to work on other NIX's
though I have tested it on Linux and FreeBSD. I am sure you guys know a much
better way of doing this.

Thanks,
Jason



begin 666 apache-chili-fix.diff
M+2TM(&AT='!?;6%I;BYC"51U92!397 @,3(@,3<Z,C Z,3,@,C P, T**RLK
M(&AT='!?;6%I;BYC"4UO;B!.;W8@,3,@,3$Z,3(Z,S@@,C P, T*0$ @+3$S
M-S4L.2 K,3,W-2PQ-R! 0 T*( D@(" @87!?<V5T7V-A;&QB86-K7V%N9%]A
M;&%R;2AA;&%R;5]F;BP@,"D[#0H@(" @('T-"B!]#0HK+RH@87!?<F5S971?
M<VEG;F%L7VUA<VL@*&EN="!S:6=N;RD@8VQE87)S(&%N>2!S<&5C:69I960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@+2!*87-O;B!'<F5E;F4@*B\-"BL@(" @87!?<F5S971?<VEG;F%L
M7VUA<VLH4TE'04Q232D[#0H@(" @('-I9VYA;"A324=!3%)-+"!A;')M7VAA
M;F1L97(I.PT*("-I9F1E9B!44$8-"B @(" @<VEG;F%L*%-)1TA54"P@:G5S
)=%]D:64I.PT*
`
end


Re: solaris + libthread + keepalive fix

Posted by Jason Greene <us...@tds.net>.
I just read the rules for the list, and I apologize for not following the rules on that last post.
If you would like me to repost a conforming message please reply.

Thanks,
Jason