]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
* qemud/qemud.c: If using FORTIFY_SOURCE, remove warning
authorRichard W.M. Jones <rjones@redhat.com>
Tue, 27 Mar 2007 10:28:45 +0000 (10:28 +0000)
committerRichard W.M. Jones <rjones@redhat.com>
Tue, 27 Mar 2007 10:28:45 +0000 (10:28 +0000)
  warn_unused_result by counting errors found in signal
  handler and logging them in the main loop.

ChangeLog
qemud/qemud.c

index 107600214acf1859eeabae533245ae9495b8c292..f35410907860da3a57af5464ceb1ea2b7b5f9fd5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Tue Mar 27 11:26:00 BST 2007 Richard W.M. Jones <rjones@redhat.com>
+
+       * qemud/qemud.c: If using FORTIFY_SOURCE, remove warning
+         warn_unused_result by counting errors found in signal
+         handler and logging them in the main loop.
+
 Mon Mar 26 11:29:43 CEST 2007 Daniel Veillard <veillard@redhat.com>
 
        * acinclude.m4: applied patch from Jim Meyering to avoid clobbering
index 30245b195af01c4cebe14f87acb4e470272af6d5..12b112c4c109810adc1309634d3078f170473e26 100644 (file)
@@ -57,15 +57,23 @@ static int godaemon = 0;
 static int verbose = 0;
 static int sigwrite = -1;
 
+static sig_atomic_t sig_errors = 0;
+static int sig_lasterrno = 0;
+
 static void sig_handler(int sig) {
     unsigned char sigc = sig;
     int origerrno;
+    int r;
 
     if (sig == SIGCHLD) /* We explicitly waitpid the child later */
         return;
 
     origerrno = errno;
-    write(sigwrite, &sigc, 1);
+    r = write(sigwrite, &sigc, 1);
+    if (r == -1) {
+        sig_errors++;
+        sig_lasterrno = errno;
+    }
     errno = origerrno;
 }
 
@@ -1655,6 +1663,7 @@ static int qemudOneLoop(struct qemud_server *server, int timeout) {
     struct pollfd fds[nfds];
     int thistimeout = -1;
     int ret;
+    sig_atomic_t errors;
 
     /* If we have no clients or vms, then timeout after
        30 seconds, letting daemon exit */
@@ -1682,6 +1691,16 @@ static int qemudOneLoop(struct qemud_server *server, int timeout) {
         return -1;
     }
 
+    /* Check for any signal handling errors and log them. */
+    errors = sig_errors;
+    if (errors) {
+        sig_errors -= errors;
+        qemudLog (QEMUD_ERR,
+                  "Signal handler reported %d errors: last error: %s",
+                  errors, strerror (sig_lasterrno));
+        return -1;
+    }
+
     if (qemudDispatchPoll(server, fds) < 0)
         return -1;