ia64/xen-unstable

diff tools/xenstore/xs_test.c @ 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 72e4e2aab342
children 9af349b055e5 3233e7ecfa9f
line diff
     1.1 --- a/tools/xenstore/xs_test.c	Tue Sep 13 21:52:24 2005 +0000
     1.2 +++ b/tools/xenstore/xs_test.c	Wed Sep 14 08:41:49 2005 +0000
     1.3 @@ -398,12 +398,16 @@ static void do_noackwrite(unsigned int h
     1.4  static void do_readack(unsigned int handle)
     1.5  {
     1.6  	enum xsd_sockmsg_type type;
     1.7 -	char *ret;
     1.8 +	char *ret = NULL;
     1.9  
    1.10 -	ret = read_reply(handles[handle]->fd, &type, NULL);
    1.11 -	if (!ret)
    1.12 -		failed(handle);
    1.13 -	free(ret);
    1.14 +	/* Watches can have fired before reply comes: daemon detects
    1.15 +	 * and re-transmits, so we can ignore this. */
    1.16 +	do {
    1.17 +		free(ret);
    1.18 +		ret = read_reply(handles[handle]->fd, &type, NULL);
    1.19 +		if (!ret)
    1.20 +			failed(handle);
    1.21 +	} while (type == XS_WATCH_EVENT);
    1.22  }
    1.23  
    1.24  static void do_setid(unsigned int handle, char *id)