diff -r 640288d0e1bc src/os/unix/ngx_atomic.h
--- a/src/os/unix/ngx_atomic.h	Tue Apr 12 19:01:56 2016 +0300
+++ b/src/os/unix/ngx_atomic.h	Mon Apr 18 18:28:52 2016 +0100
@@ -307,7 +307,14 @@
 void ngx_spinlock(ngx_atomic_t *lock, ngx_atomic_int_t value, ngx_uint_t spin);
 
 #define ngx_trylock(lock)  (*(lock) == 0 && ngx_atomic_cmp_set(lock, 0, 1))
-#define ngx_unlock(lock)    *(lock) = 0
+
+
+static ngx_inline void
+ngx_unlock(ngx_atomic_t *lock)
+{
+    ngx_memory_barrier();
+    *lock = 0;
+}
 
 
 #endif /* _NGX_ATOMIC_H_INCLUDED_ */
