Test and fix acknowedge_watch from returning EINVAL.
PATCH 3/11 Test and fix acknowedge_watch from returning EINVAL.
# HG changeset patch
# User Rusty Russell <[email protected]>
# 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 <[email protected]>
tools/xenstore/xenstored_core.c +1 -1
@@ -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
tools/xenstore/xenstored_core.h +1 -1
@@ -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;
tools/xenstore/xenstored_watch.c +10 -5
@@ -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 ); }