From 70c5967806da744dc2a3c121d89043dcceb4a260 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 15 May 2008 20:38:29 +0000 Subject: [PATCH] increase shm size limit, modernizations git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/glitch-free@2430 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/pulsecore/shm.c | 12 ++++++------ src/pulsecore/shm.h | 8 +++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/pulsecore/shm.c b/src/pulsecore/shm.c index a1bbf60..a684381 100644 --- a/src/pulsecore/shm.c +++ b/src/pulsecore/shm.c @@ -57,7 +57,7 @@ #define MADV_REMOVE 9 #endif -#define MAX_SHM_SIZE (PA_ALIGN(1024*1024*20)) +#define MAX_SHM_SIZE (PA_ALIGN(1024*1024*64)) #ifdef __linux__ /* On Linux we know that the shared memory blocks are files in @@ -86,13 +86,13 @@ static char *segment_name(char *fn, size_t l, unsigned id) { return fn; } -int pa_shm_create_rw(pa_shm *m, size_t size, int shared, mode_t mode) { +int pa_shm_create_rw(pa_shm *m, size_t size, pa_bool_t shared, mode_t mode) { char fn[32]; int fd = -1; pa_assert(m); pa_assert(size > 0); - pa_assert(size < MAX_SHM_SIZE); + pa_assert(size <= MAX_SHM_SIZE); pa_assert(mode >= 0600); /* Each time we create a new SHM area, let's first drop all stale @@ -124,7 +124,7 @@ int pa_shm_create_rw(pa_shm *m, size_t size, int shared, mode_t mode) { m->ptr = pa_xmalloc(m->size); #endif - m->do_unlink = 0; + m->do_unlink = FALSE; } else { #ifdef HAVE_SHM_OPEN @@ -157,7 +157,7 @@ int pa_shm_create_rw(pa_shm *m, size_t size, int shared, mode_t mode) { pa_atomic_store(&marker->marker, SHM_MARKER); pa_assert_se(close(fd) == 0); - m->do_unlink = 1; + m->do_unlink = TRUE; #else return -1; #endif @@ -375,7 +375,7 @@ int pa_shm_cleanup(void) { /* Ok, the owner of this shms segment is dead, so, let's remove the segment */ segment_name(fn, sizeof(fn), id); - if (shm_unlink(fn) < 0 && errno != EACCES) + if (shm_unlink(fn) < 0 && errno != EACCES && errno != ENOENT) pa_log_warn("Failed to remove SHM segment %s: %s\n", fn, pa_cstrerror(errno)); } diff --git a/src/pulsecore/shm.h b/src/pulsecore/shm.h index 270591d..60bc355 100644 --- a/src/pulsecore/shm.h +++ b/src/pulsecore/shm.h @@ -26,15 +26,17 @@ #include +#include + typedef struct pa_shm { unsigned id; void *ptr; size_t size; - int do_unlink; - int shared; + pa_bool_t do_unlink:1; + pa_bool_t shared:1; } pa_shm; -int pa_shm_create_rw(pa_shm *m, size_t size, int shared, mode_t mode); +int pa_shm_create_rw(pa_shm *m, size_t size, pa_bool_t shared, mode_t mode); int pa_shm_attach_ro(pa_shm *m, unsigned id); void pa_shm_punch(pa_shm *m, size_t offset, size_t size); -- 2.7.4