From 6922005a3850d4aa147b00603e69d82927a11447 Mon Sep 17 00:00:00 2001
From: Pedro Gonnet <gonnet@google.com>
Date: Tue, 23 Aug 2016 21:29:37 +0200
Subject: [PATCH] make update of s->maxdepth atomic.

---
 src/space.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/space.c b/src/space.c
index 5f76055f5e..8c66227180 100644
--- a/src/space.c
+++ b/src/space.c
@@ -1253,7 +1253,9 @@ void space_split_mapper(void *map_data, int num_elements, void *extra_data) {
     struct xpart *xparts = c->xparts;
 
     /* Check the depth. */
-    if (c->depth > s->maxdepth) s->maxdepth = c->depth;
+    while (c->depth > (maxdepth = s->maxdepth)) {
+      atomic_cas(&s->maxdepth, maxdepth, c->depth);
+    }
 
     /* Split or let it be? */
     if (count > space_splitsize || gcount > space_splitsize) {
-- 
GitLab