File xs-10-call-add_change_node.patch of Package xen.4507

commit b4b475c3ace316589fb9b68f9d4ee9425a1a2349
Author: Juergen Gross <jgross@suse.com>
Date:   Mon Dec 5 08:48:43 2016 +0100

    xenstore: call add_change_node() directly when writing node
    
    Instead of calling add_change_node() at places where write_node() is
    called, do that inside write_node().
    
    Note that there is one case where add_change_node() is called now when
    a later failure will prohibit the changed node to be written: in case
    of a write_node failing due to an error in tdb_store(). As the only
    visible change of behavior is a stale event fired for the node, while
    the failing tdb_store() signals a corrupted xenstore database, the
    stale event will be the least problem of this case.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Acked-by: Wei Liu <wei.liu2@citrix.com>

Index: xen-4.4.4-testing/tools/xenstore/xenstored_core.c
===================================================================
--- xen-4.4.4-testing.orig/tools/xenstore/xenstored_core.c
+++ xen-4.4.4-testing/tools/xenstore/xenstored_core.c
@@ -446,7 +446,7 @@ static struct node *read_node(struct con
 	return node;
 }
 
-static bool write_node(struct connection *conn, const struct node *node)
+static bool write_node(struct connection *conn, struct node *node)
 {
 	/*
 	 * conn will be null when this is called from manual_node.
@@ -466,6 +466,8 @@ static bool write_node(struct connection
 	if (domain_is_unprivileged(conn) && data.dsize >= quota_max_entry_size)
 		goto error;
 
+	add_change_node(conn, node, false);
+
 	data.dptr = talloc_size(node, data.dsize);
 	((uint32_t *)data.dptr)[0] = node->num_perms;
 	((uint32_t *)data.dptr)[1] = node->datalen;
@@ -966,7 +968,6 @@ static void do_write(struct connection *
 		}
 	}
 
-	add_change_node(conn, node, false);
 	fire_watches(conn, in, name, false);
 	send_ack(conn, XS_WRITE);
 }
@@ -997,7 +998,6 @@ static void do_mkdir(struct connection *
 			send_error(conn, errno);
 			return;
 		}
-		add_change_node(conn, node, false);
 		fire_watches(conn, in, name, false);
 	}
 	send_ack(conn, XS_MKDIR);
@@ -1199,7 +1199,6 @@ static void do_set_perms(struct connecti
 		return;
 	}
 
-	add_change_node(conn, node, false);
 	fire_watches(conn, in, name, false);
 	send_ack(conn, XS_SET_PERMS);
 }
openSUSE Build Service is sponsored by