diff options
Diffstat (limited to 'src/lanes.cpp')
-rw-r--r-- | src/lanes.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/lanes.cpp b/src/lanes.cpp index 87edb02..e09956c 100644 --- a/src/lanes.cpp +++ b/src/lanes.cpp | |||
@@ -973,15 +973,19 @@ LUAG_FUNC(lane_new) | |||
973 | ~OnExit() | 973 | ~OnExit() |
974 | { | 974 | { |
975 | if (m_lane) { | 975 | if (m_lane) { |
976 | STACK_CHECK_START_REL(m_L, 0); | ||
976 | // we still need a full userdata so that garbage collection can do its thing | 977 | // we still need a full userdata so that garbage collection can do its thing |
977 | prepareUserData(); | 978 | prepareUserData(); |
979 | // remove it immediately from the stack so that the error that landed us here is at the top | ||
980 | lua_pop(m_L, 1); | ||
981 | STACK_CHECK(m_L, 0); | ||
978 | // leave a single cancel_error on the stack for the caller | 982 | // leave a single cancel_error on the stack for the caller |
979 | lua_settop(m_lane->L, 0); | 983 | lua_settop(m_lane->L, 0); |
980 | kCancelError.pushKey(m_lane->L); | 984 | kCancelError.pushKey(m_lane->L); |
981 | { | 985 | { |
982 | std::lock_guard lock{ m_lane->doneMutex }; | 986 | std::lock_guard lock{ m_lane->doneMutex }; |
983 | m_lane->status = Lane::Cancelled; | 987 | // this will cause lane_main to skip actual running (because we are not Pending anymore) |
984 | m_lane->doneCondVar.notify_one(); // wake up master (while 'lane->doneMutex' is on) | 988 | m_lane->status = Lane::Running; |
985 | } | 989 | } |
986 | // unblock the thread so that it can terminate gracefully | 990 | // unblock the thread so that it can terminate gracefully |
987 | m_lane->ready.count_down(); | 991 | m_lane->ready.count_down(); |