memtrap: hook up core to memtrap system
authorLennart Poettering <lennart@poettering.net>
Tue, 21 Apr 2009 20:56:08 +0000 (22:56 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 21 Apr 2009 20:56:08 +0000 (22:56 +0200)
src/Makefile.am
src/daemon/main.c
src/pulsecore/memblock.c

index ec56c3d42289f43f33950302bbe1a317f7688616..b6db81545cf27bb38b6aeef2b8b8325ee468ef8f 100644 (file)
@@ -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 \
index c456e6d173a487f831637fcbaa6edfb1ade695d5..a232451647b4b8ed4e9589e9a3588dae11860ab0 100644 (file)
@@ -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))) {
index 6cc0ff3fbd44e7be8a73bbbd148bf45936e84994..9a57895b762daabe17dbb1b062a6a25aea25f03f 100644 (file)
@@ -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);
 }