[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.15-22-g684b4c1
Lennart Poettering
gitmailer-noreply at 0pointer.de
Tue Apr 21 13:56:12 PDT 2009
This is an automated email from the git hooks/post-receive script. It was
generated because of a push to the "PulseAudio Sound Server" repository.
The master branch has been updated
from 7b0086185fcebe671cafd4292ee0ce9e0e73c848 (commit)
- Log -----------------------------------------------------------------
684b4c1 memtrap: hook up core to memtrap system
928adf4 memtrap: make installation of SIGBUS handler explicit to ease integration into libraries
-----------------------------------------------------------------------
Summary of changes:
src/Makefile.am | 2 +-
src/daemon/main.c | 3 +++
src/pulsecore/memblock.c | 7 +++++++
src/pulsecore/memtrap.c | 38 +++++++++++++++-----------------------
src/pulsecore/memtrap.h | 2 ++
src/tests/sigbus-test.c | 1 +
6 files changed, 29 insertions(+), 24 deletions(-)
-----------------------------------------------------------------------
commit 928adf412f6d568926e00831c55c8d2d574ddc61
Author: Lennart Poettering <lennart at poettering.net>
Date: Tue Apr 21 22:54:44 2009 +0200
memtrap: make installation of SIGBUS handler explicit to ease integration into libraries
diff --git a/src/pulsecore/memtrap.c b/src/pulsecore/memtrap.c
index 4904253..a6ae510 100644
--- a/src/pulsecore/memtrap.c
+++ b/src/pulsecore/memtrap.c
@@ -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);
+}
diff --git a/src/pulsecore/memtrap.h b/src/pulsecore/memtrap.h
index d93d672..6cad296 100644
--- a/src/pulsecore/memtrap.h
+++ b/src/pulsecore/memtrap.h
@@ -35,4 +35,6 @@ void pa_memtrap_remove(pa_memtrap *m);
pa_bool_t pa_memtrap_is_good(pa_memtrap *m);
+void pa_memtrap_install(void);
+
#endif
diff --git a/src/tests/sigbus-test.c b/src/tests/sigbus-test.c
index dec4f0f..4b9ca84 100644
--- a/src/tests/sigbus-test.c
+++ b/src/tests/sigbus-test.c
@@ -35,6 +35,7 @@ int main(int argc, char *argv[]) {
pa_memtrap *m;
pa_log_set_level(PA_LOG_DEBUG);
+ pa_memtrap_install();
/* Create the memory map */
pa_assert_se((fd = open("sigbus-test-map", O_RDWR|O_TRUNC|O_CREAT, 0660)) >= 0);
commit 684b4c116c11aff8824ce12a99a16f6cb27f0661
Author: Lennart Poettering <lennart at poettering.net>
Date: Tue Apr 21 22:56:08 2009 +0200
memtrap: hook up core to memtrap system
diff --git a/src/Makefile.am b/src/Makefile.am
index ec56c3d..b6db815 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -582,6 +582,7 @@ libpulsecommon_ at PA_MAJORMINORMICRO@_la_SOURCES = \
pulsecore/pipe.c pulsecore/pipe.h \
pulsecore/poll.c pulsecore/poll.h \
pulsecore/prioq.c pulsecore/prioq.h \
+ pulsecore/memtrap.c pulsecore/memtrap.h \
pulsecore/proplist-util.c pulsecore/proplist-util.h \
pulsecore/pstream-util.c pulsecore/pstream-util.h \
pulsecore/pstream.c pulsecore/pstream.h \
@@ -804,7 +805,6 @@ libpulsecore_ at PA_MAJORMINORMICRO@_la_SOURCES = \
pulsecore/sconv-s16le.c pulsecore/sconv-s16le.h \
pulsecore/sconv.c pulsecore/sconv.h \
pulsecore/shared.c pulsecore/shared.h \
- pulsecore/memtrap.c pulsecore/memtrap.h \
pulsecore/shm.c pulsecore/shm.h \
pulsecore/sink-input.c pulsecore/sink-input.h \
pulsecore/sink.c pulsecore/sink.h \
diff --git a/src/daemon/main.c b/src/daemon/main.c
index c456e6d..a232451 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -87,6 +87,7 @@
#include <pulsecore/thread.h>
#include <pulsecore/once.h>
#include <pulsecore/shm.h>
+#include <pulsecore/memtrap.h>
#ifdef HAVE_DBUS
#include <pulsecore/dbus-shared.h>
#endif
@@ -961,6 +962,8 @@ int main(int argc, char *argv[]) {
pa_rtsig_configure(SIGRTMIN, SIGRTMAX-1);
#endif
+ pa_memtrap_install();
+
pa_assert_se(mainloop = pa_mainloop_new());
if (!(c = pa_core_new(pa_mainloop_get_api(mainloop), !conf->disable_shm, conf->shm_size))) {
diff --git a/src/pulsecore/memblock.c b/src/pulsecore/memblock.c
index 6cc0ff3..9a57895 100644
--- a/src/pulsecore/memblock.c
+++ b/src/pulsecore/memblock.c
@@ -45,6 +45,7 @@
#include <pulsecore/macro.h>
#include <pulsecore/flist.h>
#include <pulsecore/core-util.h>
+#include <pulsecore/memtrap.h>
#include "memblock.h"
@@ -91,6 +92,7 @@ struct pa_memblock {
struct pa_memimport_segment {
pa_memimport *import;
pa_shm memory;
+ pa_memtrap *trap;
unsigned n_blocks;
};
@@ -892,6 +894,7 @@ static pa_memimport_segment* segment_attach(pa_memimport *i, uint32_t shm_id) {
seg->import = i;
seg->n_blocks = 0;
+ seg->trap = pa_memtrap_add(seg->memory.ptr, seg->memory.size);
pa_hashmap_put(i->segments, PA_UINT32_TO_PTR(shm_id), seg);
return seg;
@@ -903,6 +906,10 @@ static void segment_detach(pa_memimport_segment *seg) {
pa_hashmap_remove(seg->import->segments, PA_UINT32_TO_PTR(seg->memory.id));
pa_shm_free(&seg->memory);
+
+ if (seg->trap)
+ pa_memtrap_remove(seg->trap);
+
pa_xfree(seg);
}
--
hooks/post-receive
PulseAudio Sound Server
More information about the pulseaudio-commits
mailing list