mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-04 12:52:15 +00:00
Change a "while {}" loop to a "do {} while" to allow it to be
executed at least once, fixing pthread_mutex_lock() for recursive mutex lock attempts. Correctly set a threads signal mask while it is executing a signal handler. The mask should be the union of its current mask, the signal being handled, and the mask from the signal action. Reported by: Dan Nelson <dnelson@emsphone.com> MFC Candidate
This commit is contained in:
parent
1b2da3b0e4
commit
47c1571785
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=68941
@ -427,8 +427,7 @@ pthread_mutex_lock(pthread_mutex_t * mutex)
|
||||
* Instead, the thread is interrupted and backed out of the
|
||||
* waiting queue prior to executing the signal handler.
|
||||
*/
|
||||
while (((*mutex)->m_owner != _thread_run) && (ret == 0) &&
|
||||
(_thread_run->interrupted == 0)) {
|
||||
do {
|
||||
/*
|
||||
* Defer signals to protect the scheduling queues from
|
||||
* access by the signal handler:
|
||||
@ -637,7 +636,8 @@ pthread_mutex_lock(pthread_mutex_t * mutex)
|
||||
* necessary:
|
||||
*/
|
||||
_thread_kern_sig_undefer();
|
||||
}
|
||||
} while (((*mutex)->m_owner != _thread_run) && (ret == 0) &&
|
||||
(_thread_run->interrupted == 0));
|
||||
|
||||
if (_thread_run->interrupted != 0 &&
|
||||
_thread_run->continuation != NULL)
|
||||
|
@ -1057,6 +1057,10 @@ thread_sigframe_add(pthread_t thread, int sig, int has_args)
|
||||
sizeof(psf->siginfo));
|
||||
}
|
||||
|
||||
/* Setup the signal mask: */
|
||||
SIGSETOR(thread->sigmask, _thread_sigact[sig - 1].sa_mask);
|
||||
sigaddset(&thread->sigmask, sig);
|
||||
|
||||
/* Set up the new frame: */
|
||||
thread->curframe = psf;
|
||||
thread->ctxtype = CTX_JB_NOSIG;
|
||||
|
@ -427,8 +427,7 @@ pthread_mutex_lock(pthread_mutex_t * mutex)
|
||||
* Instead, the thread is interrupted and backed out of the
|
||||
* waiting queue prior to executing the signal handler.
|
||||
*/
|
||||
while (((*mutex)->m_owner != _thread_run) && (ret == 0) &&
|
||||
(_thread_run->interrupted == 0)) {
|
||||
do {
|
||||
/*
|
||||
* Defer signals to protect the scheduling queues from
|
||||
* access by the signal handler:
|
||||
@ -637,7 +636,8 @@ pthread_mutex_lock(pthread_mutex_t * mutex)
|
||||
* necessary:
|
||||
*/
|
||||
_thread_kern_sig_undefer();
|
||||
}
|
||||
} while (((*mutex)->m_owner != _thread_run) && (ret == 0) &&
|
||||
(_thread_run->interrupted == 0));
|
||||
|
||||
if (_thread_run->interrupted != 0 &&
|
||||
_thread_run->continuation != NULL)
|
||||
|
@ -1057,6 +1057,10 @@ thread_sigframe_add(pthread_t thread, int sig, int has_args)
|
||||
sizeof(psf->siginfo));
|
||||
}
|
||||
|
||||
/* Setup the signal mask: */
|
||||
SIGSETOR(thread->sigmask, _thread_sigact[sig - 1].sa_mask);
|
||||
sigaddset(&thread->sigmask, sig);
|
||||
|
||||
/* Set up the new frame: */
|
||||
thread->curframe = psf;
|
||||
thread->ctxtype = CTX_JB_NOSIG;
|
||||
|
@ -427,8 +427,7 @@ pthread_mutex_lock(pthread_mutex_t * mutex)
|
||||
* Instead, the thread is interrupted and backed out of the
|
||||
* waiting queue prior to executing the signal handler.
|
||||
*/
|
||||
while (((*mutex)->m_owner != _thread_run) && (ret == 0) &&
|
||||
(_thread_run->interrupted == 0)) {
|
||||
do {
|
||||
/*
|
||||
* Defer signals to protect the scheduling queues from
|
||||
* access by the signal handler:
|
||||
@ -637,7 +636,8 @@ pthread_mutex_lock(pthread_mutex_t * mutex)
|
||||
* necessary:
|
||||
*/
|
||||
_thread_kern_sig_undefer();
|
||||
}
|
||||
} while (((*mutex)->m_owner != _thread_run) && (ret == 0) &&
|
||||
(_thread_run->interrupted == 0));
|
||||
|
||||
if (_thread_run->interrupted != 0 &&
|
||||
_thread_run->continuation != NULL)
|
||||
|
@ -1057,6 +1057,10 @@ thread_sigframe_add(pthread_t thread, int sig, int has_args)
|
||||
sizeof(psf->siginfo));
|
||||
}
|
||||
|
||||
/* Setup the signal mask: */
|
||||
SIGSETOR(thread->sigmask, _thread_sigact[sig - 1].sa_mask);
|
||||
sigaddset(&thread->sigmask, sig);
|
||||
|
||||
/* Set up the new frame: */
|
||||
thread->curframe = psf;
|
||||
thread->ctxtype = CTX_JB_NOSIG;
|
||||
|
Loading…
Reference in New Issue
Block a user