summaryrefslogtreecommitdiffstats
path: root/src/daemon/cpulimit.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon/cpulimit.c')
-rw-r--r--src/daemon/cpulimit.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/daemon/cpulimit.c b/src/daemon/cpulimit.c
index a61f43eb..42a71f7e 100644
--- a/src/daemon/cpulimit.c
+++ b/src/daemon/cpulimit.c
@@ -1,5 +1,3 @@
-/* $Id$ */
-
/***
This file is part of PulseAudio.
@@ -82,7 +80,7 @@ static pa_io_event *io_event = NULL;
static struct sigaction sigaction_prev;
/* Nonzero after pa_cpu_limit_init() */
-static int installed = 0;
+static pa_bool_t installed = FALSE;
/* The current state of operation */
static enum {
@@ -113,6 +111,9 @@ static void write_err(const char *p) {
/* The signal handler, called on every SIGXCPU */
static void signal_handler(int sig) {
+ int saved_errno;
+
+ saved_errno = errno;
pa_assert(sig == SIGXCPU);
if (phase == PHASE_IDLE) {
@@ -148,8 +149,10 @@ static void signal_handler(int sig) {
} else if (phase == PHASE_SOFT) {
write_err("Hard CPU time limit exhausted, terminating forcibly.\n");
- _exit(1); /* Forced exit */
+ abort(); /* Forced exit */
}
+
+ errno = saved_errno;
}
/* Callback for IO events on the FIFO */
@@ -160,7 +163,7 @@ static void callback(pa_mainloop_api*m, pa_io_event*e, int fd, pa_io_event_flags
pa_assert(f == PA_IO_EVENT_INPUT);
pa_assert(e == io_event);
pa_assert(fd == the_pipe[0]);
-
+
pa_read(the_pipe[0], &c, sizeof(c), NULL);
m->quit(m, 1); /* Quit the main loop */
}
@@ -168,7 +171,7 @@ static void callback(pa_mainloop_api*m, pa_io_event*e, int fd, pa_io_event_flags
/* Initializes CPU load limiter */
int pa_cpu_limit_init(pa_mainloop_api *m) {
struct sigaction sa;
-
+
pa_assert(m);
pa_assert(!api);
pa_assert(!io_event);
@@ -205,7 +208,7 @@ int pa_cpu_limit_init(pa_mainloop_api *m) {
return -1;
}
- installed = 1;
+ installed = TRUE;
reset_cpu_time(CPUTIME_INTERVAL_SOFT);
@@ -226,7 +229,7 @@ void pa_cpu_limit_done(void) {
if (installed) {
pa_assert_se(sigaction(SIGXCPU, &sigaction_prev, NULL) >= 0);
- installed = 0;
+ installed = FALSE;
}
}