aboutsummaryrefslogtreecommitdiffstats
path: root/tools/xenstore/xenstored_domain.c
diff options
context:
space:
mode:
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>2007-05-30 10:04:23 +0100
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>2007-05-30 10:04:23 +0100
commit29dd27927cb9cff9e97e1e6b6b25a425c30e238d (patch)
tree46e0e20e50894706f38b381b75d221af8e479deb /tools/xenstore/xenstored_domain.c
parent57e9895926c04bc586b249f4dd103c052f7a784d (diff)
downloadxen-29dd27927cb9cff9e97e1e6b6b25a425c30e238d.tar.gz
xen-29dd27927cb9cff9e97e1e6b6b25a425c30e238d.tar.bz2
xen-29dd27927cb9cff9e97e1e6b6b25a425c30e238d.zip
Fix xenstore entry accounting
xenstored is incorrectly accounting domain nodes when transactions fail. Store pending count changes in the transaction structure, and apply at transaction completion, instead of directly applying the changes. Signed-off-by: Max Zhen <max.zhen@sun.com>
Diffstat (limited to 'tools/xenstore/xenstored_domain.c')
-rw-r--r--tools/xenstore/xenstored_domain.c56
1 files changed, 45 insertions, 11 deletions
diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_domain.c
index f59ec31d56..6df0c32c64 100644
--- a/tools/xenstore/xenstored_domain.c
+++ b/tools/xenstore/xenstored_domain.c
@@ -576,12 +576,21 @@ void domain_entry_inc(struct connection *conn, struct node *node)
return;
if (node->perms && node->perms[0].id != conn->id) {
- d = find_domain_by_domid(node->perms[0].id);
- if (d)
- d->nbentry++;
- }
- else if (conn->domain) {
- conn->domain->nbentry++;
+ if (conn->transaction) {
+ transaction_entry_inc(conn->transaction,
+ node->perms[0].id);
+ } else {
+ d = find_domain_by_domid(node->perms[0].id);
+ if (d)
+ d->nbentry++;
+ }
+ } else if (conn->domain) {
+ if (conn->transaction) {
+ transaction_entry_inc(conn->transaction,
+ conn->domain->domid);
+ } else {
+ conn->domain->nbentry++;
+ }
}
}
@@ -593,11 +602,36 @@ void domain_entry_dec(struct connection *conn, struct node *node)
return;
if (node->perms && node->perms[0].id != conn->id) {
- d = find_domain_by_domid(node->perms[0].id);
- if (d && d->nbentry)
- d->nbentry--;
- } else if (conn->domain && conn->domain->nbentry)
- conn->domain->nbentry--;
+ if (conn->transaction) {
+ transaction_entry_dec(conn->transaction,
+ node->perms[0].id);
+ } else {
+ d = find_domain_by_domid(node->perms[0].id);
+ if (d && d->nbentry)
+ d->nbentry--;
+ }
+ } else if (conn->domain && conn->domain->nbentry) {
+ if (conn->transaction) {
+ transaction_entry_dec(conn->transaction,
+ conn->domain->domid);
+ } else {
+ conn->domain->nbentry--;
+ }
+ }
+}
+
+void domain_entry_fix(unsigned int domid, int num)
+{
+ struct domain *d;
+
+ d = find_domain_by_domid(domid);
+ if (d) {
+ if ((d->nbentry += num) < 0) {
+ eprintf("invalid domain entry number %d",
+ d->nbentry);
+ d->nbentry = 0;
+ }
+ }
}
int domain_entry(struct connection *conn)