diff options
Diffstat (limited to 'src/lane.cpp')
| -rw-r--r-- | src/lane.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/lane.cpp b/src/lane.cpp index 5cebdfa..e6ea2e5 100644 --- a/src/lane.cpp +++ b/src/lane.cpp | |||
| @@ -783,10 +783,14 @@ static void lane_main(Lane* const lane_) | |||
| 783 | if (lane_->selfdestructRemove()) { // check and remove (under lock!) | 783 | if (lane_->selfdestructRemove()) { // check and remove (under lock!) |
| 784 | // We're a free-running thread and no-one is there to clean us up. | 784 | // We're a free-running thread and no-one is there to clean us up. |
| 785 | lane_->closeState(); | 785 | lane_->closeState(); |
| 786 | lane_->U->selfdestructMutex.lock(); | 786 | |
| 787 | // done with lua_close(), terminal shutdown sequence may proceed | 787 | // let's try not to crash if the lane didn't terminate gracefully and the Universe met its end |
| 788 | lane_->U->selfdestructingCount.fetch_sub(1, std::memory_order_release); | 788 | if (!lane_->flaggedAfterUniverseGC.load(std::memory_order_relaxed)) { |
| 789 | lane_->U->selfdestructMutex.unlock(); | 789 | lane_->U->selfdestructMutex.lock(); |
| 790 | // done with lua_close(), terminal shutdown sequence may proceed | ||
| 791 | lane_->U->selfdestructingCount.fetch_sub(1, std::memory_order_release); | ||
| 792 | lane_->U->selfdestructMutex.unlock(); | ||
| 793 | } | ||
| 790 | 794 | ||
| 791 | // we destroy ourselves, therefore our thread member too, from inside the thread body | 795 | // we destroy ourselves, therefore our thread member too, from inside the thread body |
| 792 | // detach so that we don't try to join, as this doesn't seem a good idea | 796 | // detach so that we don't try to join, as this doesn't seem a good idea |
