diff options
author | cl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk> | 2005-07-26 15:13:56 +0000 |
---|---|---|
committer | cl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk> | 2005-07-26 15:13:56 +0000 |
commit | e04c630cb24b65d871f061074bea23174cadf841 (patch) | |
tree | 31950e1ab897968f879a0513db58b1f3f9dfe6c9 /tools/xenstore/xenstored_transaction.c | |
parent | e08ecc0000058e476a61af2b503ce34580bd63bc (diff) | |
download | xen-e04c630cb24b65d871f061074bea23174cadf841.tar.gz xen-e04c630cb24b65d871f061074bea23174cadf841.tar.bz2 xen-e04c630cb24b65d871f061074bea23174cadf841.zip |
Change from bool indicating blocked to an enum: when watches go
synchronous this makes it easier (because then we have two reasons
to block)
Instead of using return value, use explicit state member inside
struct connection.
Signed-off-by: Rusty Russel <rusty@rustcorp.com.au>
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
Diffstat (limited to 'tools/xenstore/xenstored_transaction.c')
-rw-r--r-- | tools/xenstore/xenstored_transaction.c | 45 |
1 files changed, 28 insertions, 17 deletions
diff --git a/tools/xenstore/xenstored_transaction.c b/tools/xenstore/xenstored_transaction.c index 0e8372f471..60dcf04130 100644 --- a/tools/xenstore/xenstored_transaction.c +++ b/tools/xenstore/xenstored_transaction.c @@ -114,7 +114,8 @@ bool transaction_block(struct connection *conn, const char *node) trans = transaction_covering_node(node); if (trans) { start_transaction_timeout(trans); - conn->blocked = talloc_strdup(conn, node); + conn->state = BLOCKED; + conn->blocked_by = talloc_strdup(conn, node); return true; } return false; @@ -239,20 +240,24 @@ static bool copy_dir(const char *src, const char *dst) return true; } -bool do_transaction_start(struct connection *conn, const char *node) +void do_transaction_start(struct connection *conn, const char *node) { struct transaction *transaction; char *dir; - if (conn->transaction) - return send_error(conn, EBUSY); + if (conn->transaction) { + send_error(conn, EBUSY); + return; + } node = canonicalize(conn, node); - if (!check_node_perms(conn, node, XS_PERM_READ)) - return send_error(conn, errno); + if (!check_node_perms(conn, node, XS_PERM_READ)) { + send_error(conn, errno); + return; + } if (transaction_block(conn, node)) - return true; + return; dir = node_dir_outside_transaction(node); @@ -270,12 +275,14 @@ bool do_transaction_start(struct connection *conn, const char *node) talloc_set_destructor(transaction, destroy_transaction); trace_create(transaction, "transaction"); - if (!copy_dir(dir, transaction->divert)) - return send_error(conn, errno); + if (!copy_dir(dir, transaction->divert)) { + send_error(conn, errno); + return; + } talloc_steal(conn, transaction); conn->transaction = transaction; - return send_ack(transaction->conn, XS_TRANSACTION_START); + send_ack(transaction->conn, XS_TRANSACTION_START); } static bool commit_transaction(struct transaction *trans) @@ -301,13 +308,17 @@ static bool commit_transaction(struct transaction *trans) return true; } -bool do_transaction_end(struct connection *conn, const char *arg) +void do_transaction_end(struct connection *conn, const char *arg) { - if (!arg || (!streq(arg, "T") && !streq(arg, "F"))) - return send_error(conn, EINVAL); + if (!arg || (!streq(arg, "T") && !streq(arg, "F"))) { + send_error(conn, EINVAL); + return; + } - if (!conn->transaction) - return send_error(conn, ENOENT); + if (!conn->transaction) { + send_error(conn, ENOENT); + return; + } if (streq(arg, "T")) { if (conn->transaction->destined_to_fail) { @@ -322,11 +333,11 @@ bool do_transaction_end(struct connection *conn, const char *arg) talloc_free(conn->transaction); conn->transaction = NULL; - return send_ack(conn, XS_TRANSACTION_END); + send_ack(conn, XS_TRANSACTION_END); + return; failed: talloc_free(conn->transaction); conn->transaction = NULL; - return false; } |