Closed Bug 39674 Opened 25 years ago Closed 25 years ago

Remove the Unix sigprocmask calls in prnetdb.c

Categories

(NSPR :: NSPR, defect, P3)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: wtc, Assigned: wtc)

Details

Attachments

(1 file)

In prnetdb.c, we call sigprocmask() on Unix to block the SIGALRM signal while calling gethostbyname() and gethostbyaddr(). This is a vestige of classic NSPR that can be removed. Details follow. The user-level thread scheduler in classic NSPR uses setitimer() to send periodic (every 50ms) SIGALRM signals to the process to implement thread preemption. On some Unix flavors such as HP-UX, if the select() system call is interrupted and SA_RESTART is set for the signal, the select() call is restarted with the originally specified timeout, ignoring the time that has elapsed. With a periodic SIGALRM, a select() can be repeatedly interrupted and restarted and never time out. Since gethostbyname() and gethostbyaddr() may call select() and we weren't sure if select() was wrapped properly, we added these sigprocmask() calls to block SIGALRM while calling gethostbyname() and gethostbyaddr(). These sigprocmask() calls are not needed by the pthreads version of NSPR, which is used on most Unix platforms now. In fact, they are not even needed by classic NSPR -- I verified (on HP-UX 11.00) that our select() wrapper correctly blocks the SIGALRM signal while it is calling the real select system call, so it's not necessary for PR_GetHostByName() and PR_GetHostByAddr() to block SIGALRM again. Therefore the sigprocmask() calls in prnetdb.c can be safely removed.
Attached patch Proposed patch.Splinter Review
Another Unix flavor that restarts an interrupted select() call with the original timeout is SINIX. I also verified on SINIX-N 5.43 that our select() wrapper correctly blocks SIGALRM while calling the real select system call. The patch is checked in on the main trunk. /cvsroot/mozilla/nsprpub/pr/src/misc/prnetdb.c, revision 3.14 I will add a test that verifies that the select() wrapper blocks SIGALRM.
Status: NEW → ASSIGNED
Target Milestone: --- → 4.1
I added a new test selintr.c that verifies that the select() wrapper in classic NSPR properly blocks the periodic SIGALRM clocks. Marked the bug fixed.
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: