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
This commit is contained in:
Lennart Poettering 2007-09-11 23:12:24 +00:00
parent d5bedbcd98
commit 54506ab44a
5 changed files with 134 additions and 9 deletions

View file

@ -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:

View file

@ -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

View file

@ -58,13 +58,12 @@
#include <tcpd.h>
#endif
#include "../pulsecore/winsock.h"
#include <pulse/mainloop.h>
#include <pulse/mainloop-signal.h>
#include <pulse/timeval.h>
#include <pulse/xmalloc.h>
#include <pulsecore/winsock.h>
#include <pulsecore/core-error.h>
#include <pulsecore/core.h>
#include <pulsecore/memblock.h>
@ -83,6 +82,7 @@
#include <pulsecore/mutex.h>
#include <pulsecore/thread.h>
#include <pulsecore/once.h>
#include <pulsecore/shm.h>
#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);
}