WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Fire watches once immediately upon registration.

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Fire watches once immediately upon registration.
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 19 Sep 2005 16:04:12 +0000
Delivery-date: Mon, 19 Sep 2005 16:02:55 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User cl349@xxxxxxxxxxxxxxxxxxxx
# Node ID 2796d45c58356cf8554a07dcc73038a95c6f1ecc
# Parent  0a2cc72ee6e47287ffc27b1dac4a4e6a1741f952
Fire watches once immediately upon registration.
It matches the model of programming used to avoid races with watches,
and also makes re-establishing watches on daemon restart easier.
Signed-off-by: Rusty Russell <rusty@xxxxxxxxxxxxxxx>
Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>

diff -r 0a2cc72ee6e4 -r 2796d45c5835 
linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c Mon Sep 19 14:36:15 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c Mon Sep 19 14:47:56 2005
@@ -228,6 +228,7 @@
        be->dev = dev;
        be->backend_watch.node = dev->nodename;
        be->backend_watch.callback = backend_changed;
+       /* Will implicitly call backend_changed once. */
        err = register_xenbus_watch(&be->backend_watch);
        if (err) {
                be->backend_watch.node = NULL;
@@ -249,8 +250,6 @@
        }
 
        dev->data = be;
-
-       backend_changed(&be->backend_watch, dev->nodename);
        return 0;
 
  free_be:
diff -r 0a2cc72ee6e4 -r 2796d45c5835 
linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c  Mon Sep 19 14:36:15 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c  Mon Sep 19 14:47:56 2005
@@ -172,6 +172,7 @@
        be->dev = dev;
        be->backend_watch.node = dev->nodename;
        be->backend_watch.callback = backend_changed;
+       /* Registration implicitly fires backend_changed once */
        err = register_xenbus_watch(&be->backend_watch);
        if (err) {
                be->backend_watch.node = NULL;
@@ -193,8 +194,6 @@
        }
 
        dev->data = be;
-
-       backend_changed(&be->backend_watch, dev->nodename);
        return 0;
 
  free_be:
diff -r 0a2cc72ee6e4 -r 2796d45c5835 
linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c Mon Sep 19 14:36:15 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c Mon Sep 19 14:47:56 2005
@@ -242,6 +242,7 @@
        be->dev = dev;
        be->backend_watch.node = dev->nodename;
        be->backend_watch.callback = backend_changed;
+       /* Registration implicitly calls backend_changed. */
        err = register_xenbus_watch(&be->backend_watch);
        if (err) {
                be->backend_watch.node = NULL;
@@ -263,8 +264,6 @@
        }
 
        dev->data = be;
-
-       backend_changed(&be->backend_watch, dev->nodename);
        return 0;
 
  free_be:
diff -r 0a2cc72ee6e4 -r 2796d45c5835 
linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c      Mon Sep 19 
14:36:15 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c      Mon Sep 19 
14:47:56 2005
@@ -1284,10 +1284,6 @@
                return err;
        }
 
-
-       /* Call once in case entries already there. */
-       watch_for_status(&info->watch, info->watch.node);
-
        return 0;
 }
 
diff -r 0a2cc72ee6e4 -r 2796d45c5835 
linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c Mon Sep 19 14:36:15 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c Mon Sep 19 14:47:56 2005
@@ -213,6 +213,7 @@
 
        be->dev = dev;
        be->backend_watch.node     = dev->nodename;
+       /* Implicitly calls backend_changed() once. */
        be->backend_watch.callback = backend_changed;
        be->instance = -1;
        err = register_xenbus_watch(&be->backend_watch);
@@ -236,8 +237,6 @@
        }
 
        dev->data = be;
-
-       backend_changed(&be->backend_watch, dev->nodename);
        return err;
 
 free_be:
diff -r 0a2cc72ee6e4 -r 2796d45c5835 
linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c      Mon Sep 19 
14:36:15 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c      Mon Sep 19 
14:47:56 2005
@@ -411,7 +411,6 @@
                return err;
        }
 
-       watch_for_status(&info->watch, info->watch.node);
        return 0;
 }
 
diff -r 0a2cc72ee6e4 -r 2796d45c5835 tools/xenstore/testsuite/07watch.test
--- a/tools/xenstore/testsuite/07watch.test     Mon Sep 19 14:36:15 2005
+++ b/tools/xenstore/testsuite/07watch.test     Mon Sep 19 14:47:56 2005
@@ -168,10 +168,12 @@
 # Watch event must have happened before we registered interest.
 1 watch / token
 2 write /test/subnode contents2
-1 watch / token2 0
+1 watchnoack / token2 0
 expect 1:/test/subnode:token
 1 waitwatch
 1 ackwatch token
+expect 1:/:token2
+1 waitwatch
 expect 1: waitwatch failed: Connection timed out
 1 waitwatch
 1 close
diff -r 0a2cc72ee6e4 -r 2796d45c5835 
tools/xenstore/testsuite/14complexperms.test
--- a/tools/xenstore/testsuite/14complexperms.test      Mon Sep 19 14:36:15 2005
+++ b/tools/xenstore/testsuite/14complexperms.test      Mon Sep 19 14:47:56 2005
@@ -23,7 +23,8 @@
 getperm /dir/file 
 expect *Permission denied
 setperm /dir/file 0 NONE 
-watch /dir/file token 
+# We get no watch event when there's no permission.  It's a corner case.
+watchnoack /dir/file token 
 1 write /dir/file contents
 1 rm /dir/file
 expect waitwatch failed: Connection timed out
@@ -63,7 +64,7 @@
 getperm /dir/file 
 expect *Permission denied
 setperm /dir/file 0 NONE 
-watch /dir/file token 
+watchnoack /dir/file token 
 1 write /dir/file contents
 1 rm /dir/file
 expect waitwatch failed: Connection timed out
diff -r 0a2cc72ee6e4 -r 2796d45c5835 tools/xenstore/xenstored_watch.c
--- a/tools/xenstore/xenstored_watch.c  Mon Sep 19 14:36:15 2005
+++ b/tools/xenstore/xenstored_watch.c  Mon Sep 19 14:47:56 2005
@@ -236,6 +236,9 @@
        trace_create(watch, "watch");
        talloc_set_destructor(watch, destroy_watch);
        send_ack(conn, XS_WATCH);
+
+       /* We fire once up front: simplifies clients and restart. */
+       add_event(conn, watch, watch->node);
 }
 
 void do_watch_ack(struct connection *conn, const char *token)
diff -r 0a2cc72ee6e4 -r 2796d45c5835 tools/xenstore/xs_test.c
--- a/tools/xenstore/xs_test.c  Mon Sep 19 14:36:15 2005
+++ b/tools/xenstore/xs_test.c  Mon Sep 19 14:47:56 2005
@@ -200,6 +200,7 @@
             "  setperm <path> <id> <flags> ...\n"
             "  shutdown\n"
             "  watch <path> <token>\n"
+            "  watchnoack <path> <token>\n"
             "  waitwatch\n"
             "  ackwatch <token>\n"
             "  unwatch <path> <token>\n"
@@ -480,10 +481,20 @@
                failed(handle);
 }
 
-static void do_watch(unsigned int handle, const char *node, const char *token)
+static void do_watch(unsigned int handle, const char *node, const char *token,
+                    bool swallow_event)
 {
        if (!xs_watch(handles[handle], node, token))
                failed(handle);
+
+       /* Convenient for testing... */
+       if (swallow_event) {
+               char **vec = xs_read_watch(handles[handle]);
+               if (!vec || !streq(vec[0], node) || !streq(vec[1], token))
+                       failed(handle);
+               if (!xs_acknowledge_watch(handles[handle], token))
+                       failed(handle);
+       }
 }
 
 static void set_timeout(void)
@@ -767,7 +778,9 @@
        else if (streq(command, "shutdown"))
                do_shutdown(handle);
        else if (streq(command, "watch"))
-               do_watch(handle, arg(line, 1), arg(line, 2));
+               do_watch(handle, arg(line, 1), arg(line, 2), true);
+       else if (streq(command, "watchnoack"))
+               do_watch(handle, arg(line, 1), arg(line, 2), false);
        else if (streq(command, "waitwatch"))
                do_waitwatch(handle);
        else if (streq(command, "ackwatch"))

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Fire watches once immediately upon registration., Xen patchbot -unstable <=