ia64/xen-unstable

changeset 6823:c63529f3367d

Fix xenstored watch crash.
When a connection blocked waiting on a transaction, don't queue watch events.
Sure, they'd be ignored and re-transmitted, but it hits an assert that we don't
send data out blocked connections, and it's wasteful.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (authored)
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Wed Sep 14 08:41:49 2005 +0000 (2005-09-14)
parents 0d8c0db04258
children 0a7194ec36a4
files tools/xenstore/testsuite/16block-watch-crash.test tools/xenstore/xenstored_watch.c tools/xenstore/xs_test.c
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tools/xenstore/testsuite/16block-watch-crash.test	Wed Sep 14 08:41:49 2005 +0000
     1.3 @@ -0,0 +1,13 @@
     1.4 +# Test case where blocked connection gets sent watch.
     1.5 +
     1.6 +mkdir /test
     1.7 +watch /test token
     1.8 +1 start /test
     1.9 +# This will block on above
    1.10 +noackwrite /test/entry create contents
    1.11 +1 write /test/entry2 create contents
    1.12 +1 commit
    1.13 +readack
    1.14 +expect /test/entry2:token
    1.15 +waitwatch
    1.16 +ackwatch token
     2.1 --- a/tools/xenstore/xenstored_watch.c	Tue Sep 13 21:52:24 2005 +0000
     2.2 +++ b/tools/xenstore/xenstored_watch.c	Wed Sep 14 08:41:49 2005 +0000
     2.3 @@ -144,7 +144,7 @@ void fire_watches(struct connection *con
     2.4  			else
     2.5  				continue;
     2.6  			/* If connection not doing anything, queue this. */
     2.7 -			if (!i->out)
     2.8 +			if (i->state == OK)
     2.9  				queue_next_event(i);
    2.10  		}
    2.11  	}
     3.1 --- a/tools/xenstore/xs_test.c	Tue Sep 13 21:52:24 2005 +0000
     3.2 +++ b/tools/xenstore/xs_test.c	Wed Sep 14 08:41:49 2005 +0000
     3.3 @@ -398,12 +398,16 @@ static void do_noackwrite(unsigned int h
     3.4  static void do_readack(unsigned int handle)
     3.5  {
     3.6  	enum xsd_sockmsg_type type;
     3.7 -	char *ret;
     3.8 +	char *ret = NULL;
     3.9  
    3.10 -	ret = read_reply(handles[handle]->fd, &type, NULL);
    3.11 -	if (!ret)
    3.12 -		failed(handle);
    3.13 -	free(ret);
    3.14 +	/* Watches can have fired before reply comes: daemon detects
    3.15 +	 * and re-transmits, so we can ignore this. */
    3.16 +	do {
    3.17 +		free(ret);
    3.18 +		ret = read_reply(handles[handle]->fd, &type, NULL);
    3.19 +		if (!ret)
    3.20 +			failed(handle);
    3.21 +	} while (type == XS_WATCH_EVENT);
    3.22  }
    3.23  
    3.24  static void do_setid(unsigned int handle, char *id)