session: support reclaiming pending apply session
[project/rpcd.git] / uci.c
diff --git a/uci.c b/uci.c
index 72ae5a67f99ae8f00784be8e2aa94eff5d3116e4..91d4ba23b78f1dc38343683975dd4db1164648cf 100644 (file)
--- a/uci.c
+++ b/uci.c
@@ -30,7 +30,8 @@ static struct blob_buf buf;
 static struct uci_context *cursor;
 static struct uloop_timeout apply_timer;
 static struct ubus_context *apply_ctx;
-static char apply_sid[RPC_SID_LEN + 1];
+
+char apply_sid[RPC_SID_LEN + 1];
 
 enum {
        RPC_G_CONFIG,
@@ -210,8 +211,15 @@ rpc_uci_status(void)
 static void
 rpc_uci_set_savedir(struct blob_attr *sid)
 {
+       struct uci_element *e, *tmp;
        char path[PATH_MAX];
 
+       uci_foreach_element_safe(&cursor->delta_path, tmp, e)
+               free(e);
+
+       cursor->delta_path.prev = &cursor->delta_path;
+       cursor->delta_path.next = &cursor->delta_path;
+
        if (!sid)
        {
                uci_set_savedir(cursor, "/tmp/.uci");