]> git.kaiwu.me - njs.git/commitdiff
Modules: fix shared dict state save error ordering
authorDmitry Volyntsev <xeioex@nginx.com>
Sat, 10 Oct 2026 01:03:47 +0000 (18:03 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Thu, 15 Oct 2026 01:49:05 +0000 (18:49 -0700)
On save failure, writing is cleared before dirty is restored.  Another
worker can observe a clean, idle zone and stop retrying.  If the failed
writer is exiting, it also stops retrying and the changes remain unsaved.

Set dirty first and add a memory barrier before clearing writing to
publish the need for another save before releasing the writer.

nginx/ngx_js_shared_dict.c

index 30de86bf86d9a52128319ee9643f3f81d15a05e2..f324fd0cb730f82b217f9c59c2d67e1505c78929 100644 (file)
@@ -2694,9 +2694,12 @@ error:
 
     ngx_destroy_pool(pool);
 
+    dict->sh->dirty = 1;
+
+    ngx_memory_barrier();
+
     /* no lock required */
     dict->sh->writing = 0;
-    dict->sh->dirty = 1;
 
     return NGX_ERROR;
 }