[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] xenstored: Do not write to stderr if we are daemonised!



# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1185969310 -3600
# Node ID 0c79a9414f8db20706a10db2b586f1a1770193e3
# Parent  eabac09d9e4e0005bd1024858c9fd5b938290e16
xenstored: Do not write to stderr if we are daemonised!
This fixes client reader-thread deaths in which a 'garbage string' was
being read instead of a well-formed message header.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 tools/xenstore/utils.c            |   11 +++++------
 tools/xenstore/xenstored_core.c   |    9 ++++++++-
 tools/xenstore/xenstored_domain.c |    9 ++-------
 tools/xenstore/xs_tdb_dump.c      |    2 +-
 4 files changed, 16 insertions(+), 15 deletions(-)

diff -r eabac09d9e4e -r 0c79a9414f8d tools/xenstore/utils.c
--- a/tools/xenstore/utils.c    Wed Aug 01 12:05:42 2007 +0100
+++ b/tools/xenstore/utils.c    Wed Aug 01 12:55:10 2007 +0100
@@ -8,20 +8,19 @@
 #include <fcntl.h>
 #include <sys/types.h>
 #include <signal.h>
-
 #include "utils.h"
 
 void xprintf(const char *fmt, ...)
 {
-       static FILE *out = NULL;
        va_list args;
-       if (!out)
-               out = stderr;
+
+       if (!stderr)
+               return; /* could trace()? */
 
        va_start(args, fmt);
-       vfprintf(out, fmt, args);
+       vfprintf(stderr, fmt, args);
        va_end(args);
-       fflush(out);
+       fflush(stderr);
 }
 
 void barf(const char *fmt, ...)
diff -r eabac09d9e4e -r 0c79a9414f8d tools/xenstore/xenstored_core.c
--- a/tools/xenstore/xenstored_core.c   Wed Aug 01 12:05:42 2007 +0100
+++ b/tools/xenstore/xenstored_core.c   Wed Aug 01 12:55:10 2007 +0100
@@ -1820,7 +1820,9 @@ int main(int argc, char *argv[])
        if (pidfile)
                write_pidfile(pidfile);
 
-       talloc_enable_leak_report_full();
+       /* Talloc leak reports go to stderr, which is closed if we fork. */
+       if (!dofork)
+               talloc_enable_leak_report_full();
 
        /* Create sockets for them to listen to. */
        sock = talloc(talloc_autofree_context(), int);
@@ -1881,6 +1883,11 @@ int main(int argc, char *argv[])
                close(STDIN_FILENO);
                close(STDOUT_FILENO);
                close(STDERR_FILENO);
+
+               /* Get ourselves a nice xenstored crash if these are used. */
+               stdin = NULL;
+               stdout = NULL;
+               stderr = NULL;
        }
 
        signal(SIGHUP, trigger_reopen_log);
diff -r eabac09d9e4e -r 0c79a9414f8d tools/xenstore/xenstored_domain.c
--- a/tools/xenstore/xenstored_domain.c Wed Aug 01 12:05:42 2007 +0100
+++ b/tools/xenstore/xenstored_domain.c Wed Aug 01 12:55:10 2007 +0100
@@ -621,13 +621,8 @@ void domain_entry_fix(unsigned int domid
        struct domain *d;
 
        d = find_domain_by_domid(domid);
-       if (d) {
-               if ((d->nbentry += num) < 0) {
-                       eprintf("invalid domain entry number %d",
-                               d->nbentry);
-                       d->nbentry = 0;
-               }
-       }
+       if (d && ((d->nbentry += num) < 0))
+               d->nbentry = 0;
 }
 
 int domain_entry(struct connection *conn)
diff -r eabac09d9e4e -r 0c79a9414f8d tools/xenstore/xs_tdb_dump.c
--- a/tools/xenstore/xs_tdb_dump.c      Wed Aug 01 12:05:42 2007 +0100
+++ b/tools/xenstore/xs_tdb_dump.c      Wed Aug 01 12:55:10 2007 +0100
@@ -4,7 +4,7 @@
 #include <fcntl.h>
 #include <stdio.h>
 #include <stdarg.h>
-
+#include <string.h>
 #include "xs_lib.h"
 #include "tdb.h"
 #include "talloc.h"

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.