From fb962b67dbeb54d1cdd453c6f902b7c679b9197f Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 3 Sep 2004 22:44:55 +0000 Subject: add option to disallow module loading after startup git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@177 fefdeb5f-60dc-0310-8127-8f9354f1896f --- polyp/cpulimit.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'polyp/cpulimit.c') 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; -- cgit