From 54506ab44a9ac61e79b3a5c632db56bde41beded Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 11 Sep 2007 23:12:24 +0000 Subject: on systems where we know that POSIX shm is mapped to /dev/shm, add the ability to cleanup stale SHM segments. (Right now only Linux) git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1810 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/daemon/cmdline.c | 9 ++++++++- src/daemon/daemon-conf.h | 3 ++- src/daemon/main.c | 11 +++++++++-- 3 files changed, 19 insertions(+), 4 deletions(-) (limited to 'src/daemon') diff --git a/src/daemon/cmdline.c b/src/daemon/cmdline.c index a3f1ff03..d14002f6 100644 --- a/src/daemon/cmdline.c +++ b/src/daemon/cmdline.c @@ -64,7 +64,8 @@ enum { ARG_NO_CPU_LIMIT, ARG_DISABLE_SHM, ARG_DUMP_RESAMPLE_METHODS, - ARG_SYSTEM + ARG_SYSTEM, + ARG_CLEANUP_SHM }; /* Tabel for getopt_long() */ @@ -94,6 +95,7 @@ static struct option long_options[] = { {"no-cpu-limit", 2, 0, ARG_NO_CPU_LIMIT}, {"disable-shm", 2, 0, ARG_DISABLE_SHM}, {"dump-resample-methods", 2, 0, ARG_DUMP_RESAMPLE_METHODS}, + {"cleanup-shm", 2, 0, ARG_CLEANUP_SHM}, {NULL, 0, 0, 0} }; @@ -114,6 +116,7 @@ void pa_cmdline_help(const char *argv0) { " --dump-conf Dump default configuration\n" " --dump-modules Dump list of available modules\n" " --dump-resample-methods Dump available resample methods\n" + " --cleanup-shm Cleanup stale shared memory segments\n" " -k --kill Kill a running daemon\n" " --check Check for a running daemon\n\n" @@ -188,6 +191,10 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d case ARG_DUMP_RESAMPLE_METHODS: conf->cmd = PA_CMD_DUMP_RESAMPLE_METHODS; break; + + case ARG_CLEANUP_SHM: + conf->cmd = PA_CMD_CLEANUP_SHM; + break; case 'k': case ARG_KILL: diff --git a/src/daemon/daemon-conf.h b/src/daemon/daemon-conf.h index 76334271..4d37861d 100644 --- a/src/daemon/daemon-conf.h +++ b/src/daemon/daemon-conf.h @@ -41,7 +41,8 @@ typedef enum pa_daemon_conf_cmd { PA_CMD_DUMP_MODULES, PA_CMD_KILL, PA_CMD_CHECK, - PA_CMD_DUMP_RESAMPLE_METHODS + PA_CMD_DUMP_RESAMPLE_METHODS, + PA_CMD_CLEANUP_SHM } pa_daemon_conf_cmd_t; #ifdef HAVE_SYS_RESOURCE_H diff --git a/src/daemon/main.c b/src/daemon/main.c index 87f3f01d..4509e7f9 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -58,13 +58,12 @@ #include #endif -#include "../pulsecore/winsock.h" - #include #include #include #include +#include #include #include #include @@ -83,6 +82,7 @@ #include #include #include +#include #include "cmdline.h" #include "cpulimit.h" @@ -496,6 +496,13 @@ int main(int argc, char *argv[]) { goto finish; + case PA_CMD_CLEANUP_SHM: + + if (pa_shm_cleanup() >= 0) + retval = 0; + + goto finish; + default: pa_assert(conf->cmd == PA_CMD_DAEMON); } -- cgit