send_reply(conn, XS_READ, node->data, node->datalen);
}
-static void delete_node_single(struct connection *conn, struct node *node)
+static void delete_node_single(struct connection *conn, struct node *node,
+ bool changed)
{
TDB_DATA key;
corrupt(conn, "Could not delete '%s'", node->name);
return;
}
+
+ if (changed)
+ add_change_node(conn, node, true);
+
domain_entry_dec(conn, node);
}
}
}
- add_change_node(conn->transaction, name, false);
+ add_change_node(conn, node, false);
fire_watches(conn, in, name, false);
send_ack(conn, XS_WRITE);
}
send_error(conn, errno);
return;
}
- add_change_node(conn->transaction, name, false);
+ add_change_node(conn, node, false);
fire_watches(conn, in, name, false);
}
send_ack(conn, XS_MKDIR);
}
-static void delete_node(struct connection *conn, struct node *node)
+static void delete_node(struct connection *conn, struct node *node,
+ bool changed)
{
unsigned int i;
/* Delete self, then delete children. If we crash, then the worst
that can happen is the children will continue to take up space, but
will otherwise be unreachable. */
- delete_node_single(conn, node);
+ delete_node_single(conn, node, changed);
/* Delete children, too. */
for (i = 0; i < node->childlen; i += strlen(node->children+i) + 1) {
talloc_asprintf(node, "%s/%s", node->name,
node->children + i));
if (child) {
- delete_node(conn, child);
+ delete_node(conn, child, false);
}
else {
trace("delete_node: No child '%s/%s' found!\n",
return 0;
}
- delete_node(conn, node);
+ delete_node(conn, node, true);
return 1;
}
}
if (_rm(conn, node, name)) {
- add_change_node(conn->transaction, name, true);
fire_watches(conn, in, name, true);
send_ack(conn, XS_RM);
}
return;
}
- add_change_node(conn->transaction, name, false);
+ add_change_node(conn, node, false);
fire_watches(conn, in, name, false);
send_ack(conn, XS_SET_PERMS);
}
/* Callers get a change node (which can fail) and only commit after they've
* finished. This way they don't have to unwind eg. a write. */
-void add_change_node(struct transaction *trans, const char *node, bool recurse)
+void add_change_node(struct connection *conn, struct node *node, bool recurse)
{
struct changed_node *i;
+ struct transaction *trans;
- if (!trans) {
+ if (!conn || !conn->transaction) {
/* They're changing the global database. */
generation++;
return;
}
+ trans = conn->transaction;
+
list_for_each_entry(i, &trans->changes, list) {
- if (streq(i->node, node)) {
+ if (streq(i->node, node->name)) {
if (recurse)
i->recurse = recurse;
return;
}
i = talloc(trans, struct changed_node);
- i->node = talloc_strdup(i, node);
+ i->node = talloc_strdup(i, node->name);
i->recurse = recurse;
list_add_tail(&i->list, &trans->changes);
}