ia64/xen-unstable

changeset 5876:b9903985e9b6

Fix bug where transaction fires multiple events.
Add general trace() call to help future debugging.
Signed-off-by: Rusty Russel <rusty@rustcorp.com.au>
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Tue Jul 26 15:24:28 2005 +0000 (2005-07-26)
parents 052208a34902
children 1853a6e966bd
files tools/xenstore/testsuite/08transaction.sh tools/xenstore/xenstored_core.c tools/xenstore/xenstored_core.h tools/xenstore/xenstored_watch.c
line diff
     1.1 --- a/tools/xenstore/testsuite/08transaction.sh	Tue Jul 26 15:23:50 2005 +0000
     1.2 +++ b/tools/xenstore/testsuite/08transaction.sh	Tue Jul 26 15:24:28 2005 +0000
     1.3 @@ -79,3 +79,15 @@ 2 rm /test/dir
     1.4  2 async commit
     1.5  1 waitwatch
     1.6  1 ackwatch token' | ./xs_test 2>&1`" = "1:/test/dir/sub:token" ]
     1.7 +
     1.8 +# Multiple events from single transaction don't trigger assert
     1.9 +[ "`echo -e '1 watch /test token
    1.10 +2 start /test
    1.11 +2 write /test/1 create contents
    1.12 +2 write /test/2 create contents
    1.13 +2 async commit
    1.14 +1 waitwatch
    1.15 +1 ackwatch token
    1.16 +1 waitwatch
    1.17 +1 ackwatch token' | ./xs_test 2>&1`" = "1:/test/1:token
    1.18 +1:/test/2:token" ]
     2.1 --- a/tools/xenstore/xenstored_core.c	Tue Jul 26 15:23:50 2005 +0000
     2.2 +++ b/tools/xenstore/xenstored_core.c	Tue Jul 26 15:24:28 2005 +0000
     2.3 @@ -111,6 +111,8 @@ void __attribute__((noreturn)) corrupt(s
     2.4  	str = talloc_vasprintf(NULL, fmt, arglist);
     2.5  	va_end(arglist);
     2.6  
     2.7 +	trace("xenstored corruption: connection id %i: err %s: %s",
     2.8 +		conn ? (int)conn->id : -1, strerror(saved_errno), str);
     2.9  	eprintf("xenstored corruption: connection id %i: err %s: %s",
    2.10  		conn ? (int)conn->id : -1, strerror(saved_errno), str);
    2.11  #ifdef TESTING
    2.12 @@ -230,6 +232,21 @@ static void trace_blocked(const struct c
    2.13  	write(tracefd, ")\n", 2);
    2.14  }
    2.15  
    2.16 +void trace(const char *fmt, ...)
    2.17 +{
    2.18 +	va_list arglist;
    2.19 +	char *str;
    2.20 +
    2.21 +	if (tracefd < 0)
    2.22 +		return;
    2.23 +
    2.24 +	va_start(arglist, fmt);
    2.25 +	str = talloc_vasprintf(NULL, fmt, arglist);
    2.26 +	va_end(arglist);
    2.27 +	write(tracefd, str, strlen(str));
    2.28 +	talloc_free(str);
    2.29 +}
    2.30 +
    2.31  static bool write_message(struct connection *conn)
    2.32  {
    2.33  	int ret;
     3.1 --- a/tools/xenstore/xenstored_core.h	Tue Jul 26 15:23:50 2005 +0000
     3.2 +++ b/tools/xenstore/xenstored_core.h	Tue Jul 26 15:24:28 2005 +0000
     3.3 @@ -170,5 +170,6 @@ void *read_all(int *fd, unsigned int *si
     3.4  void trace_create(const void *data, const char *type);
     3.5  void trace_destroy(const void *data, const char *type);
     3.6  void trace_watch_timeout(const struct connection *conn, const char *node, const char *token);
     3.7 +void trace(const char *fmt, ...);
     3.8  
     3.9  #endif /* _XENSTORED_CORE_H */
     4.1 --- a/tools/xenstore/xenstored_watch.c	Tue Jul 26 15:23:50 2005 +0000
     4.2 +++ b/tools/xenstore/xenstored_watch.c	Tue Jul 26 15:24:28 2005 +0000
     4.3 @@ -134,8 +134,6 @@ bool fire_watches(struct connection *con
     4.4  	if (conn->transaction)
     4.5  		return false;
     4.6  
     4.7 -	assert(conn->state == OK);
     4.8 -
     4.9  	/* Create an event for each watch.  Don't send to self. */
    4.10  	list_for_each_entry(i, &connections, list) {
    4.11  		if (i == conn)