Re: Problem interrupting threads in PR_Accept() wiht PR_Interrupt()
Joachim Ziegler <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.nspr |
|---|---|
| Message-ID | <[email protected]> |
Wan-Teh Chang wrote:
> You can use PR_BlockInterrupt and PR_UnblockInterrupt to
> block and unblock PR_Interrupt. I just checked our implementation.
> We're not checking the "interrupt blocked" flag in some places,
> for example,
> http://mxr.mozilla.org/nspr/source/nsprpub/pr/src/pthreads/ptio.c#601
>
> 599 rv = poll(&tmp_pfd, 1, msecs);
> 600
> 601 if (self->state & PT_THREAD_ABORTED) <=== BUG
> 602 {
> 603 self->state &= ~PT_THREAD_ABORTED;
> 604 op->result.code = -1;
> 605 op->syserrno = EINTR;
> 606 op->status = pt_continuation_done;
> 607 return;
> 608 }
>
> We should be using if (_PT_THREAD_INTERRUPTED(self))
> on line 601. If you want to use this approach, we'll need to fix
> this bug. You can search for all such tests in ptio.c and change
> them to use the _PT_THREAD_INTERRUPTED macro.
Hello Wan-Teh,
I did exactly what you proposed: Compiled my own version of nspr-4.7.1
with having blindly (since I do not know what I am really doing)
substituted every occurrence of
if (self->state & PT_THREAD_ABORTED)
by
if (_PT_THREAD_INTERRUPTED(self))
(This happened 4 times, in lines 459, 520, 601 and 659.)
Then I used the approach of issuing PR_BlockInterrupt() after
PR_Accept() and PR_UnblockInterrupt() before PR_Accept().
But my worker threads are still interrupted during a PR_TransmitFile():
[...]
[17504] Thread 4 got request: GET /www/hugefile.msi HTTP/1.1
MASTER[17504]: Sending interrupt signal to worker threads.
MASTER[17504]: Thread 0 is blocked. Sent PR_Interrupt.
MASTER[17504]: Thread 1 is blocked. Sent PR_Interrupt.
MASTER[17504]: Thread 2 is blocked. Sent PR_Interrupt.
MASTER[17504]: Thread 3 is blocked. Sent PR_Interrupt.
MASTER[17504]: Thread 4 is blocked. Sent PR_Interrupt.
MASTER[17504]: Joining worker threads.
oops: PR_TransmitFile in do_cat: -5993: Operation interrupted by another
thread
[17504] Thread 4 is shutting down.
oops: PR_TransmitFile in do_cat: -5993: Operation interrupted by another
thread
[17504] Thread 2 is shutting down.
oops: PR_TransmitFile in do_cat: -5993: Operation interrupted by another
thread
[17504] Thread 0 is shutting down.
[...]