diff options
author | Julien Grall <julien.grall@citrix.com> | 2012-12-17 18:04:54 +0000 |
---|---|---|
committer | Julien Grall <julien.grall@citrix.com> | 2012-12-17 18:04:54 +0000 |
commit | b6372f16d3f1cf48cd2ff21ab4bdc25cc05d69fd (patch) | |
tree | fdae973b00e47cc10a1bbf6ad239e30017f34731 /tools/xenstore/xenstore.h | |
parent | 77ad1faa6b6147770feece6a59e21b28c0e0788f (diff) | |
download | xen-b6372f16d3f1cf48cd2ff21ab4bdc25cc05d69fd.tar.gz xen-b6372f16d3f1cf48cd2ff21ab4bdc25cc05d69fd.tar.bz2 xen-b6372f16d3f1cf48cd2ff21ab4bdc25cc05d69fd.zip |
libxenstore: filter watch events in libxenstore when we unwatch
XenStore puts in queued watch events via a thread and notifies the user.
Sometimes xs_unwatch is called before all related message is read. The use
case is non-threaded libevent, we have two event A and B:
- Event A will destroy something and call xs_unwatch;
- Event B is used to notify that a node has changed in XenStore.
As the event is called one by one, event A can be handled before event B.
So on next xs_watch_read the user could retrieve an unwatch token and
a segfault occured if the token store the pointer of the structure
(ie: "backend:0xcafe").
To avoid problem with previous application using libXenStore, this behaviour
will only be enabled if XS_UNWATCH_FILTER is given to xs_open.
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Julien Grall <julien.grall@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
Diffstat (limited to 'tools/xenstore/xenstore.h')
-rw-r--r-- | tools/xenstore/xenstore.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tools/xenstore/xenstore.h b/tools/xenstore/xenstore.h index 7259e49cd6..fdf5e764ba 100644 --- a/tools/xenstore/xenstore.h +++ b/tools/xenstore/xenstore.h @@ -27,6 +27,27 @@ #define XS_OPEN_READONLY 1UL<<0 #define XS_OPEN_SOCKETONLY 1UL<<1 +/* + * Setting XS_UNWATCH_FILTER arranges that after xs_unwatch, no + * related watch events will be delivered via xs_read_watch. But + * this relies on the couple token, subpath is unique. + * + * XS_UNWATCH_FILTER clear XS_UNWATCH_FILTER set + * + * Even after xs_unwatch, "stale" After xs_unwatch returns, no + * instances of the watch event watch events with the same + * may be delivered. token and with the same subpath + * will be delivered. + * + * A path and a subpath can be The application must avoid + * register with the same token. registering a path (/foo/) and + * a subpath (/foo/bar) with the + * same path until a successful + * xs_unwatch for the first watch + * has returned. + */ +#define XS_UNWATCH_FILTER 1UL<<2 + struct xs_handle; typedef uint32_t xs_transaction_t; |