From 3ed9219f9f7a7b0f71843aa1ca05b5d3cf5cf016 Mon Sep 17 00:00:00 2001
From: Guus Sliepen <guus@meshlink.io>
Date: Wed, 3 Feb 2021 23:30:36 +0100
Subject: [PATCH] Don't clear node dirty flag in meshlink_stop().

It's node_write_config() itself that should unset the dirty flag, depending
on the storage policy and if storage succeeded. Otherwise, we risk that
setting the storage policy back to ENABLED after calling meshlink_stop()
will not cause pending updates to be written out by meshlink_close().
---
 src/meshlink.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/meshlink.c b/src/meshlink.c
index 26bcada7..da730551 100644
--- a/src/meshlink.c
+++ b/src/meshlink.c
@@ -1846,7 +1846,9 @@ void meshlink_stop(meshlink_handle_t *mesh) {
 	if(mesh->nodes) {
 		for splay_each(node_t, n, mesh->nodes) {
 			if(n->status.dirty) {
-				n->status.dirty = !node_write_config(mesh, n, false);
+				if(!node_write_config(mesh, n, false)) {
+					// ignore
+				}
 			}
 		}
 	}
-- 
2.39.5