mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-12-15 08:56:34 -05:00
add option to disallow module loading after startup
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@177 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
4a9239f808
commit
fb962b67db
8 changed files with 34 additions and 10 deletions
1
doc/todo
1
doc/todo
|
|
@ -17,7 +17,6 @@
|
||||||
- add sample directory
|
- add sample directory
|
||||||
- paman: show scache and sample size
|
- paman: show scache and sample size
|
||||||
- add timing parameter to write callback of stream in client API
|
- add timing parameter to write callback of stream in client API
|
||||||
- add option for disabling module loading
|
|
||||||
|
|
||||||
** later ***
|
** later ***
|
||||||
- xmlrpc/http
|
- xmlrpc/http
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,7 @@ void pa_cmdline_help(const char *argv0) {
|
||||||
" -C Open a command line on the running TTY\n"
|
" -C Open a command line on the running TTY\n"
|
||||||
" -n Don't load configuration file (%s)\n"
|
" -n Don't load configuration file (%s)\n"
|
||||||
" -D Daemonize after loading the modules\n"
|
" -D Daemonize after loading the modules\n"
|
||||||
|
" -d Disallow module loading after startup\n"
|
||||||
" -f Dont quit when the startup fails\n"
|
" -f Dont quit when the startup fails\n"
|
||||||
" -v Verbose startup\n"
|
" -v Verbose startup\n"
|
||||||
" -h Show this help\n"
|
" -h Show this help\n"
|
||||||
|
|
@ -88,13 +89,19 @@ struct pa_cmdline* pa_cmdline_parse(int argc, char * const argv []) {
|
||||||
assert(argc && argv);
|
assert(argc && argv);
|
||||||
|
|
||||||
cmdline = pa_xmalloc(sizeof(struct pa_cmdline));
|
cmdline = pa_xmalloc(sizeof(struct pa_cmdline));
|
||||||
cmdline->daemonize = cmdline->help = cmdline->verbose = cmdline->high_priority = cmdline->stay_root = cmdline->version = 0;
|
cmdline->daemonize =
|
||||||
|
cmdline->help =
|
||||||
|
cmdline->verbose =
|
||||||
|
cmdline->high_priority =
|
||||||
|
cmdline->stay_root =
|
||||||
|
cmdline->version =
|
||||||
|
cmdline->disallow_module_loading = 0;
|
||||||
cmdline->fail = 1;
|
cmdline->fail = 1;
|
||||||
|
|
||||||
buf = pa_strbuf_new();
|
buf = pa_strbuf_new();
|
||||||
assert(buf);
|
assert(buf);
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "L:F:CDhfvrRVn")) != -1) {
|
while ((c = getopt(argc, argv, "L:F:CDhfvrRVnd")) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'L':
|
case 'L':
|
||||||
pa_strbuf_printf(buf, "load %s\n", optarg);
|
pa_strbuf_printf(buf, "load %s\n", optarg);
|
||||||
|
|
@ -129,7 +136,9 @@ struct pa_cmdline* pa_cmdline_parse(int argc, char * const argv []) {
|
||||||
case 'n':
|
case 'n':
|
||||||
no_default_config_file = 1;
|
no_default_config_file = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'd':
|
||||||
|
cmdline->disallow_module_loading = 1;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
|
|
||||||
struct pa_cmdline {
|
struct pa_cmdline {
|
||||||
int daemonize, help, fail, verbose, high_priority, stay_root, version;
|
int daemonize, help, fail, verbose, high_priority, stay_root, version, disallow_module_loading;
|
||||||
char *cli_commands;
|
char *cli_commands;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,8 @@ struct pa_core* pa_core_new(struct pa_mainloop_api *m) {
|
||||||
|
|
||||||
c->memblock_stat = pa_memblock_stat_new();
|
c->memblock_stat = pa_memblock_stat_new();
|
||||||
|
|
||||||
|
c->disallow_module_loading = 0;
|
||||||
|
|
||||||
pa_check_for_sigpipe();
|
pa_check_for_sigpipe();
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,8 @@ struct pa_core {
|
||||||
struct pa_subscription *subscriptions;
|
struct pa_subscription *subscriptions;
|
||||||
|
|
||||||
struct pa_memblock_stat *memblock_stat;
|
struct pa_memblock_stat *memblock_stat;
|
||||||
|
|
||||||
|
int disallow_module_loading;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct pa_core* pa_core_new(struct pa_mainloop_api *m);
|
struct pa_core* pa_core_new(struct pa_mainloop_api *m);
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@
|
||||||
#include "cpulimit.h"
|
#include "cpulimit.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
/* Utilize this much CPU time at most */
|
/* Utilize this much CPU time at maximum */
|
||||||
#define CPUTIME_PERCENT 70
|
#define CPUTIME_PERCENT 70
|
||||||
|
|
||||||
#define CPUTIME_INTERVAL_SOFT (5)
|
#define CPUTIME_INTERVAL_SOFT (5)
|
||||||
|
|
@ -77,12 +77,17 @@ static void signal_handler(int sig) {
|
||||||
|
|
||||||
if (phase == PHASE_IDLE) {
|
if (phase == PHASE_IDLE) {
|
||||||
time_t now;
|
time_t now;
|
||||||
|
|
||||||
|
#ifdef PRINT_CPU_LOAD
|
||||||
char t[256];
|
char t[256];
|
||||||
|
#endif
|
||||||
|
|
||||||
time(&now);
|
time(&now);
|
||||||
|
|
||||||
|
#ifdef PRINT_CPU_LOAD
|
||||||
snprintf(t, sizeof(t), "Using %0.1f%% CPU\n", (double)CPUTIME_INTERVAL_SOFT/(now-last_time)*100);
|
snprintf(t, sizeof(t), "Using %0.1f%% CPU\n", (double)CPUTIME_INTERVAL_SOFT/(now-last_time)*100);
|
||||||
write_err(t);
|
write_err(t);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (CPUTIME_INTERVAL_SOFT >= ((now-last_time)*(double)CPUTIME_PERCENT/100)) {
|
if (CPUTIME_INTERVAL_SOFT >= ((now-last_time)*(double)CPUTIME_PERCENT/100)) {
|
||||||
static const char c = 'X';
|
static const char c = 'X';
|
||||||
|
|
@ -115,7 +120,6 @@ static void callback(struct pa_mainloop_api*m, struct pa_io_event*e, int fd, enu
|
||||||
}
|
}
|
||||||
|
|
||||||
int pa_cpu_limit_init(struct pa_mainloop_api *m) {
|
int pa_cpu_limit_init(struct pa_mainloop_api *m) {
|
||||||
int r;
|
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
assert(m && !api && !io_event && the_pipe[0] == -1 && the_pipe[1] == -1);
|
assert(m && !api && !io_event && the_pipe[0] == -1 && the_pipe[1] == -1);
|
||||||
|
|
||||||
|
|
@ -141,8 +145,10 @@ int pa_cpu_limit_init(struct pa_mainloop_api *m) {
|
||||||
sigemptyset(&sa.sa_mask);
|
sigemptyset(&sa.sa_mask);
|
||||||
sa.sa_flags = SA_RESTART;
|
sa.sa_flags = SA_RESTART;
|
||||||
|
|
||||||
r = sigaction(SIGXCPU, &sa, &sigaction_prev);
|
if (sigaction(SIGXCPU, &sa, &sigaction_prev) < 0) {
|
||||||
assert(r >= 0);
|
pa_cpu_limit_done();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
installed = 1;
|
installed = 1;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -211,6 +211,9 @@ int main(int argc, char *argv[]) {
|
||||||
retval = 0;
|
retval = 0;
|
||||||
if (cmdline->daemonize)
|
if (cmdline->daemonize)
|
||||||
pa_loop_write(daemon_pipe[1], &retval, sizeof(retval));
|
pa_loop_write(daemon_pipe[1], &retval, sizeof(retval));
|
||||||
|
|
||||||
|
c->disallow_module_loading = cmdline->disallow_module_loading;
|
||||||
|
|
||||||
fprintf(stderr, __FILE__": mainloop entry.\n");
|
fprintf(stderr, __FILE__": mainloop entry.\n");
|
||||||
if (pa_mainloop_run(mainloop, &retval) < 0)
|
if (pa_mainloop_run(mainloop, &retval) < 0)
|
||||||
retval = 1;
|
retval = 1;
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,9 @@ struct pa_module* pa_module_load(struct pa_core *c, const char *name, const char
|
||||||
|
|
||||||
assert(c && name);
|
assert(c && name);
|
||||||
|
|
||||||
|
if (c->disallow_module_loading)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
m = pa_xmalloc(sizeof(struct pa_module));
|
m = pa_xmalloc(sizeof(struct pa_module));
|
||||||
|
|
||||||
m->name = pa_xstrdup(name);
|
m->name = pa_xstrdup(name);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue