email@example.com said: I'm doing development of multi-threaded application for AIX 4.3.3 platform. While browing through the C-SDK sources (both 0.9.4 and 0.9.7) I found out <sigprocmask> at <libldap/os-ip.c> in <nsldapi_connection_to_host>. To me, the call is potentially dangerous and <sigthreadmask> has to be used instead. Am I right or am I missing something? I am not sure if this is a bug or not. According to the Solaris 8 man page: "In a multithreaded program, the call to sigpromask() impacts only the calling thread's signal mask and is there- fore identical to a call to thr_sigsetmask(3THR). What does the AIX 4.3.3 man page say?
According to the man page it would appear that this call is threadsafe. sigprocmask - examine and change blocked signals SYNOPSIS #include <signal.h> int sigprocmask (how, set, oset) int how; sigset_t *set, *oset; DESCRIPTION The sigprocmask function is used to examine or change (or both) the calling process's signal mask. If the value of set is not NULL, it points to a set of signals to be used to change the currently blocked set. The value of how indicates the manner in which the set is changed, and consists of one of the following values, as defined in the header <signal.h>: SIG_BLOCK The resulting set shall be the union of the current set and the signal set pointed to by set. SIG_UNBLOCK The resulting set shall be the intersection of the current set and the complement of the signal set pointed to by set. SIG_SETMASK The resulting set shall be the signal set pointed to by the argument set. If oset is not NULL, the previous mask is stored in the space pointed to by oset. If the value of set is NULL, the value of how is not significant and the process's signal mask is unchanged by this function call; thus, the call can be used to inquire about currently blocked signals. If there are any pending unblocked signals after the call to sigprocmask, at least one of those signals is delivered before sigprocmask returns. It is impossible to block the SIGKILL and SIGSTOP signals; this is enforced by the system without causing an error to be indicated. If any of the SIGFPE, SIGLL or SIGSEGV signals are generated while they are blocked, the result is undefined, unless the signal was generated by a call to the kill function. If sigprocmask fails, the process's signal mask is not changed by this function call. On sucessful completion, a value of zero is returned. Otherwise, a value of -1 is returned and errno is set to indicate the error. If the following condition occurs, sigprocmask returns -1 and sets errno to the corresponding value: [EINVAL] The value of how is not equal to one of the defined values. THREAD-SAFETY NOTES sigprocmask: Thread-safe. SEE ALSO sigaction(2), sigemptyset(2), sigpending(2), sigset(2), sigsuspend(2)
On most operatinjg systems, sigprocmask() is MT safe and it only affects the calling thread. But the AIX 4.3 and AIX5 sigprocmask() man pages includes this note: Note: The sigprocmask, sigsetmask, and sigblock subroutines must not be used in a multi-threaded application. The sigthreadmask subroutine must be used instead. I have a patch.
Fixed on the trunk: mozilla/directory/c-sdk/ldap/include/portable.h new revision: 5.2; previous revision: 5.1 mozilla/directory/c-sdk/ldap/libraries/libldap/charray.c new revision: 5.1; previous revision: 5.0 mozilla/directory/c-sdk/ldap/libraries/libldap/os-ip.c new revision: 5.3; previous revision: 5.2 Fix bug # 99068 - Can't compile on NetBSD. Fix bug # 121276 - use sigthreadmask instead of sigprocmask (AIX). Fix bug # 81584 - strtok use and STRTOK on Linux. The charray() code now uses strtok_r() if available. strtok_r() is now used everywhere on Linux if available.