diff --git a/src/cell.c b/src/cell.c index e0218673e3646511d7433e85bb592c9e86ed44cf..76a90016abc68a97136dc153eb9592591b09a464 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; } }