summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/daemon/main.c3
-rw-r--r--src/pulsecore/memblock.c7
3 files changed, 11 insertions, 1 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index ec56c3d4..b6db8154 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -582,6 +582,7 @@ libpulsecommon_@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_@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 c456e6d1..a2324516 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 6cc0ff3f..9a57895b 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);
}