# HG changeset patch
# User Rusty Russell <rusty@xxxxxxxxxxxxxxx>
# Node ID 70ea61257cebc00212defe1dbed6de26c2edcf30
# Parent e158ae50d2613b3e01d41c395b8dbc34c9766f73
Test and fix acknowedge_watch from returning EINVAL.
Also ensure that daemon re-xmits event if they ack wrong thing (otherwise
confused clients get stuck, as we will send no more data while awaiting ack).
Signed-off-by: Rusty Russell <rusty@xxxxxxxxxxxxxxx>
diff -r e158ae50d261 -r 70ea61257ceb tools/xenstore/xenstored_core.c
--- a/tools/xenstore/xenstored_core.c Thu Aug 4 09:18:42 2005
+++ b/tools/xenstore/xenstored_core.c Thu Aug 4 09:28:24 2005
@@ -1162,7 +1162,7 @@
/* We might get a command while waiting for an ack: this means
* the other end discarded it: we will re-transmit. */
if (type != XS_WATCH_ACK)
- conn->waiting_for_ack = false;
+ conn->waiting_for_ack = NULL;
/* Careful: process_message may free connection. We detach
* "in" beforehand and allocate the new buffer to avoid
diff -r e158ae50d261 -r 70ea61257ceb tools/xenstore/xenstored_core.h
--- a/tools/xenstore/xenstored_core.h Thu Aug 4 09:18:42 2005
+++ b/tools/xenstore/xenstored_core.h Thu Aug 4 09:28:24 2005
@@ -64,7 +64,7 @@
bool can_write;
/* Are we waiting for a watch event ack? */
- bool waiting_for_ack;
+ struct watch *waiting_for_ack;
/* Buffered incoming data. */
struct buffered_data *in;
diff -r e158ae50d261 -r 70ea61257ceb tools/xenstore/xenstored_watch.c
--- a/tools/xenstore/xenstored_watch.c Thu Aug 4 09:18:42 2005
+++ b/tools/xenstore/xenstored_watch.c Thu Aug 4 09:28:24 2005
@@ -102,7 +102,7 @@
if (conn->waiting_reply) {
conn->out = conn->waiting_reply;
conn->waiting_reply = NULL;
- conn->waiting_for_ack = false;
+ conn->waiting_for_ack = NULL;
return;
}
@@ -115,7 +115,7 @@
return;
/* If we decide to cancel, we will reset this. */
- conn->waiting_for_ack = true;
+ conn->waiting_for_ack = event->watches[0];
/* If we deleted /foo and they're watching /foo/bar, that's what we
* tell them has changed. */
@@ -347,12 +347,17 @@
if (!conn->waiting_for_ack)
return send_error(conn, ENOENT);
- event = get_first_event(conn);
- if (!streq(event->watches[0]->token, token))
+ event = list_top(&conn->waiting_for_ack->events,
+ struct watch_event, list);
+ assert(event->watches[0] == conn->waiting_for_ack);
+ if (!streq(conn->waiting_for_ack->token, token)) {
+ /* They're confused: this will cause us to send event again */
+ conn->waiting_for_ack = NULL;
return send_error(conn, EINVAL);
+ }
move_event_onwards(event);
- conn->waiting_for_ack = false;
+ conn->waiting_for_ack = NULL;
return send_ack(conn, XS_WATCH_ACK);
}
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|