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:
Lennart Poettering 2004-09-03 22:44:55 +00:00
parent 4a9239f808
commit fb962b67db
8 changed files with 34 additions and 10 deletions

View file

@ -17,7 +17,6 @@
- add sample directory
- paman: show scache and sample size
- add timing parameter to write callback of stream in client API
- add option for disabling module loading
** later ***
- xmlrpc/http

View file

@ -72,6 +72,7 @@ void pa_cmdline_help(const char *argv0) {
" -C Open a command line on the running TTY\n"
" -n Don't load configuration file (%s)\n"
" -D Daemonize after loading the modules\n"
" -d Disallow module loading after startup\n"
" -f Dont quit when the startup fails\n"
" -v Verbose startup\n"
" -h Show this help\n"
@ -88,13 +89,19 @@ struct pa_cmdline* pa_cmdline_parse(int argc, char * const argv []) {
assert(argc && argv);
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;
buf = pa_strbuf_new();
assert(buf);
while ((c = getopt(argc, argv, "L:F:CDhfvrRVn")) != -1) {
while ((c = getopt(argc, argv, "L:F:CDhfvrRVnd")) != -1) {
switch (c) {
case 'L':
pa_strbuf_printf(buf, "load %s\n", optarg);
@ -127,9 +134,11 @@ struct pa_cmdline* pa_cmdline_parse(int argc, char * const argv []) {
cmdline->version = 1;
break;
case 'n':
no_default_config_file =1;
no_default_config_file = 1;
break;
case 'd':
cmdline->disallow_module_loading = 1;
break;
default:
goto fail;
}

View file

@ -24,7 +24,7 @@
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;
};

View file

@ -69,6 +69,8 @@ struct pa_core* pa_core_new(struct pa_mainloop_api *m) {
c->subscriptions = NULL;
c->memblock_stat = pa_memblock_stat_new();
c->disallow_module_loading = 0;
pa_check_for_sigpipe();

View file

@ -46,6 +46,8 @@ struct pa_core {
struct pa_subscription *subscriptions;
struct pa_memblock_stat *memblock_stat;
int disallow_module_loading;
};
struct pa_core* pa_core_new(struct pa_mainloop_api *m);

View file

@ -31,7 +31,7 @@
#include "cpulimit.h"
#include "util.h"
/* Utilize this much CPU time at most */
/* Utilize this much CPU time at maximum */
#define CPUTIME_PERCENT 70
#define CPUTIME_INTERVAL_SOFT (5)
@ -77,12 +77,17 @@ static void signal_handler(int sig) {
if (phase == PHASE_IDLE) {
time_t now;
#ifdef PRINT_CPU_LOAD
char t[256];
#endif
time(&now);
#ifdef PRINT_CPU_LOAD
snprintf(t, sizeof(t), "Using %0.1f%% CPU\n", (double)CPUTIME_INTERVAL_SOFT/(now-last_time)*100);
write_err(t);
#endif
if (CPUTIME_INTERVAL_SOFT >= ((now-last_time)*(double)CPUTIME_PERCENT/100)) {
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 r;
struct sigaction sa;
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);
sa.sa_flags = SA_RESTART;
r = sigaction(SIGXCPU, &sa, &sigaction_prev);
assert(r >= 0);
if (sigaction(SIGXCPU, &sa, &sigaction_prev) < 0) {
pa_cpu_limit_done();
return -1;
}
installed = 1;

View file

@ -211,6 +211,9 @@ int main(int argc, char *argv[]) {
retval = 0;
if (cmdline->daemonize)
pa_loop_write(daemon_pipe[1], &retval, sizeof(retval));
c->disallow_module_loading = cmdline->disallow_module_loading;
fprintf(stderr, __FILE__": mainloop entry.\n");
if (pa_mainloop_run(mainloop, &retval) < 0)
retval = 1;

View file

@ -54,6 +54,9 @@ struct pa_module* pa_module_load(struct pa_core *c, const char *name, const char
assert(c && name);
if (c->disallow_module_loading)
goto fail;
m = pa_xmalloc(sizeof(struct pa_module));
m->name = pa_xstrdup(name);