# HG changeset patch
# User cl349@xxxxxxxxxxxxxxxxxxxx
# Node ID c63529f3367d0285ebe9d8287dfbfabc66a8cdbd
# Parent 0d8c0db042580571be501be5b59cb5beb8417cef
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@xxxxxxxxxxxxxxx> (authored)
Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>
diff -r 0d8c0db04258 -r c63529f3367d tools/xenstore/xenstored_watch.c
--- a/tools/xenstore/xenstored_watch.c Tue Sep 13 21:52:24 2005
+++ b/tools/xenstore/xenstored_watch.c Wed Sep 14 08:41:49 2005
@@ -144,7 +144,7 @@
else
continue;
/* If connection not doing anything, queue this. */
- if (!i->out)
+ if (i->state == OK)
queue_next_event(i);
}
}
diff -r 0d8c0db04258 -r c63529f3367d tools/xenstore/xs_test.c
--- a/tools/xenstore/xs_test.c Tue Sep 13 21:52:24 2005
+++ b/tools/xenstore/xs_test.c Wed Sep 14 08:41:49 2005
@@ -398,12 +398,16 @@
static void do_readack(unsigned int handle)
{
enum xsd_sockmsg_type type;
- char *ret;
-
- ret = read_reply(handles[handle]->fd, &type, NULL);
- if (!ret)
- failed(handle);
- free(ret);
+ char *ret = NULL;
+
+ /* Watches can have fired before reply comes: daemon detects
+ * and re-transmits, so we can ignore this. */
+ do {
+ free(ret);
+ ret = read_reply(handles[handle]->fd, &type, NULL);
+ if (!ret)
+ failed(handle);
+ } while (type == XS_WATCH_EVENT);
}
static void do_setid(unsigned int handle, char *id)
diff -r 0d8c0db04258 -r c63529f3367d
tools/xenstore/testsuite/16block-watch-crash.test
--- /dev/null Tue Sep 13 21:52:24 2005
+++ b/tools/xenstore/testsuite/16block-watch-crash.test Wed Sep 14 08:41:49 2005
@@ -0,0 +1,13 @@
+# Test case where blocked connection gets sent watch.
+
+mkdir /test
+watch /test token
+1 start /test
+# This will block on above
+noackwrite /test/entry create contents
+1 write /test/entry2 create contents
+1 commit
+readack
+expect /test/entry2:token
+waitwatch
+ackwatch token
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|