ia64/xen-unstable

changeset 15687:0c79a9414f8d

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@xensource.com>
author kfraser@localhost.localdomain
date Wed Aug 01 12:55:10 2007 +0100 (2007-08-01)
parents eabac09d9e4e
children 88bb0d305308 bf85b467ee89
files tools/xenstore/utils.c tools/xenstore/xenstored_core.c tools/xenstore/xenstored_domain.c tools/xenstore/xs_tdb_dump.c
line diff
     1.1 --- a/tools/xenstore/utils.c	Wed Aug 01 12:05:42 2007 +0100
     1.2 +++ b/tools/xenstore/utils.c	Wed Aug 01 12:55:10 2007 +0100
     1.3 @@ -8,20 +8,19 @@
     1.4  #include <fcntl.h>
     1.5  #include <sys/types.h>
     1.6  #include <signal.h>
     1.7 -
     1.8  #include "utils.h"
     1.9  
    1.10  void xprintf(const char *fmt, ...)
    1.11  {
    1.12 -	static FILE *out = NULL;
    1.13  	va_list args;
    1.14 -	if (!out)
    1.15 -		out = stderr;
    1.16 +
    1.17 +	if (!stderr)
    1.18 +		return; /* could trace()? */
    1.19  
    1.20  	va_start(args, fmt);
    1.21 -	vfprintf(out, fmt, args);
    1.22 +	vfprintf(stderr, fmt, args);
    1.23  	va_end(args);
    1.24 -	fflush(out);
    1.25 +	fflush(stderr);
    1.26  }
    1.27  
    1.28  void barf(const char *fmt, ...)
     2.1 --- a/tools/xenstore/xenstored_core.c	Wed Aug 01 12:05:42 2007 +0100
     2.2 +++ b/tools/xenstore/xenstored_core.c	Wed Aug 01 12:55:10 2007 +0100
     2.3 @@ -1820,7 +1820,9 @@ int main(int argc, char *argv[])
     2.4  	if (pidfile)
     2.5  		write_pidfile(pidfile);
     2.6  
     2.7 -	talloc_enable_leak_report_full();
     2.8 +	/* Talloc leak reports go to stderr, which is closed if we fork. */
     2.9 +	if (!dofork)
    2.10 +		talloc_enable_leak_report_full();
    2.11  
    2.12  	/* Create sockets for them to listen to. */
    2.13  	sock = talloc(talloc_autofree_context(), int);
    2.14 @@ -1881,6 +1883,11 @@ int main(int argc, char *argv[])
    2.15  		close(STDIN_FILENO);
    2.16  		close(STDOUT_FILENO);
    2.17  		close(STDERR_FILENO);
    2.18 +
    2.19 +		/* Get ourselves a nice xenstored crash if these are used. */
    2.20 +		stdin = NULL;
    2.21 +		stdout = NULL;
    2.22 +		stderr = NULL;
    2.23  	}
    2.24  
    2.25  	signal(SIGHUP, trigger_reopen_log);
     3.1 --- a/tools/xenstore/xenstored_domain.c	Wed Aug 01 12:05:42 2007 +0100
     3.2 +++ b/tools/xenstore/xenstored_domain.c	Wed Aug 01 12:55:10 2007 +0100
     3.3 @@ -621,13 +621,8 @@ void domain_entry_fix(unsigned int domid
     3.4  	struct domain *d;
     3.5  
     3.6  	d = find_domain_by_domid(domid);
     3.7 -	if (d) {
     3.8 -		if ((d->nbentry += num) < 0) {
     3.9 -			eprintf("invalid domain entry number %d",
    3.10 -				d->nbentry);
    3.11 -			d->nbentry = 0;
    3.12 -		}
    3.13 -	}
    3.14 +	if (d && ((d->nbentry += num) < 0))
    3.15 +		d->nbentry = 0;
    3.16  }
    3.17  
    3.18  int domain_entry(struct connection *conn)
     4.1 --- a/tools/xenstore/xs_tdb_dump.c	Wed Aug 01 12:05:42 2007 +0100
     4.2 +++ b/tools/xenstore/xs_tdb_dump.c	Wed Aug 01 12:55:10 2007 +0100
     4.3 @@ -4,7 +4,7 @@
     4.4  #include <fcntl.h>
     4.5  #include <stdio.h>
     4.6  #include <stdarg.h>
     4.7 -
     4.8 +#include <string.h>
     4.9  #include "xs_lib.h"
    4.10  #include "tdb.h"
    4.11  #include "talloc.h"