summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/todo1
-rw-r--r--polyp/cmdline.c17
-rw-r--r--polyp/cmdline.h2
-rw-r--r--polyp/core.c2
-rw-r--r--polyp/core.h2
-rw-r--r--polyp/cpulimit.c14
-rw-r--r--polyp/main.c3
-rw-r--r--polyp/module.c3
8 files changed, 34 insertions, 10 deletions
diff --git a/doc/todo b/doc/todo
index 0da2a2e0..bfc29fab 100644
--- a/doc/todo
+++ b/doc/todo
@@ -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
diff --git a/polyp/cmdline.c b/polyp/cmdline.c
index c07e7bdc..265e0ec8 100644
--- a/polyp/cmdline.c
+++ b/polyp/cmdline.c
@@ -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;
}
diff --git a/polyp/cmdline.h b/polyp/cmdline.h
index 6a7f4dd7..7330a716 100644
--- a/polyp/cmdline.h
+++ b/polyp/cmdline.h
@@ -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;
};
diff --git a/polyp/core.c b/polyp/core.c
index 908564c1..da6ace6a 100644
--- a/polyp/core.c
+++ b/polyp/core.c
@@ -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();
diff --git a/polyp/core.h b/polyp/core.h
index a297d4e0..ffcd018b 100644
--- a/polyp/core.h
+++ b/polyp/core.h
@@ -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);
diff --git a/polyp/cpulimit.c b/polyp/cpulimit.c
index 822e1f33..7d6fa861 100644
--- a/polyp/cpulimit.c
+++ b/polyp/cpulimit.c
@@ -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;
diff --git a/polyp/main.c b/polyp/main.c
index eba15c35..1c09276e 100644
--- a/polyp/main.c
+++ b/polyp/main.c
@@ -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;
diff --git a/polyp/module.c b/polyp/module.c
index eb8a8acd..fc714953 100644
--- a/polyp/module.c
+++ b/polyp/module.c
@@ -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);