diff options
author | Lennart Poettering <lennart@poettering.net> | 2004-09-03 22:44:55 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2004-09-03 22:44:55 +0000 |
commit | fb962b67dbeb54d1cdd453c6f902b7c679b9197f (patch) | |
tree | 8e74e21d2a976ca7c328ed698edeb0591dcea66e /polyp/cpulimit.c | |
parent | 4a9239f808b08cf391ded6052bab9cc499e4b505 (diff) |
add option to disallow module loading after startup
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@177 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'polyp/cpulimit.c')
-rw-r--r-- | polyp/cpulimit.c | 14 |
1 files changed, 10 insertions, 4 deletions
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; |