mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-06 13:29:56 -05:00
memtrap: make installation of SIGBUS handler explicit to ease integration into libraries
This commit is contained in:
parent
7b0086185f
commit
928adf412f
3 changed files with 18 additions and 23 deletions
|
|
@ -154,21 +154,6 @@ pa_memtrap* pa_memtrap_add(const void *start, size_t size) {
|
|||
lock = pa_static_mutex_get(&write_lock, FALSE, FALSE);
|
||||
pa_mutex_lock(lock);
|
||||
|
||||
if (!memtraps[0]) {
|
||||
struct sigaction sa;
|
||||
|
||||
/* Before we install the signal handler, make sure the
|
||||
* semaphore is valid so that the initialization of the
|
||||
* semaphore doesn't have to happen from the signal handler */
|
||||
pa_static_semaphore_get(&semaphore, 0);
|
||||
|
||||
memset(&sa, 0, sizeof(sa));
|
||||
sa.sa_sigaction = signal_handler;
|
||||
sa.sa_flags = SA_RESTART|SA_SIGINFO;
|
||||
|
||||
pa_assert_se(sigaction(SIGBUS, &sa, NULL) == 0);
|
||||
}
|
||||
|
||||
n = (unsigned) pa_atomic_load(&read_lock);
|
||||
j = WHICH(n);
|
||||
|
||||
|
|
@ -204,14 +189,6 @@ void pa_memtrap_remove(pa_memtrap *m) {
|
|||
|
||||
pa_xfree(m);
|
||||
|
||||
if (!memtraps[0]) {
|
||||
struct sigaction sa;
|
||||
|
||||
memset(&sa, 0, sizeof(sa));
|
||||
sa.sa_handler = SIG_DFL;
|
||||
pa_assert_se(sigaction(SIGBUS, &sa, NULL) == 0);
|
||||
}
|
||||
|
||||
pa_mutex_unlock(lock);
|
||||
}
|
||||
|
||||
|
|
@ -255,3 +232,18 @@ unlock:
|
|||
|
||||
return m;
|
||||
}
|
||||
|
||||
void pa_memtrap_install(void) {
|
||||
struct sigaction sa;
|
||||
|
||||
/* Before we install the signal handler, make sure the semaphore
|
||||
* is valid so that the initialization of the semaphore
|
||||
* doesn't have to happen from the signal handler */
|
||||
pa_static_semaphore_get(&semaphore, 0);
|
||||
|
||||
memset(&sa, 0, sizeof(sa));
|
||||
sa.sa_sigaction = signal_handler;
|
||||
sa.sa_flags = SA_RESTART|SA_SIGINFO;
|
||||
|
||||
pa_assert_se(sigaction(SIGBUS, &sa, NULL) == 0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue