From dc99b5bf1f4ccdc22d2d80411f50606e94f60720 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <matthieu.schaller@durham.ac.uk> Date: Fri, 27 Jul 2018 14:00:15 +0100 Subject: [PATCH] Use careful locks and unlocks around the activation of the gravity drifts. --- src/cell.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/cell.c b/src/cell.c index e0218673e3..76a90016ab 100644 --- a/src/cell.c +++ b/src/cell.c @@ -1435,16 +1435,24 @@ void cell_activate_drift_gpart(struct cell *c, struct scheduler *s) { /* Set the do_grav_sub_drifts all the way up and activate the super drift if this has not yet been done. */ if (c == c->super_gravity) { + + /* Lock the cell and actuivate things */ + if(lock_lock(&c->lock) != 0) error("Error trying to lock cell"); if(c->drift_gpart == NULL) error("Trying to activate un-existing c->drift_gpart"); - scheduler_activate(s, c->drift_gpart); + if(c->drift_gpart != NULL) scheduler_activate(s, c->drift_gpart); + if(lock_unlock(&c->lock) != 0) error("Error trying to unlock cell"); } else { for (struct cell *parent = c->parent; parent != NULL && !parent->do_grav_sub_drift; parent = parent->parent) { parent->do_grav_sub_drift = 1; if (parent == c->super_gravity) { + + /* Lock the cell and actuivate things */ + if(lock_lock(&parent->lock) != 0) error("Error trying to lock parent cell"); if(parent->drift_gpart == NULL) error("Trying to activate un-existing parent->drift_gpart"); - scheduler_activate(s, parent->drift_gpart); + if(parent->drift_gpart != NULL)scheduler_activate(s, parent->drift_gpart); + if(lock_unlock(&parent->lock) != 0) error("Error trying to unlock parent cell"); break; } } -- GitLab