aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenoit Germain <benoit.germain@ubisoft.com>2024-05-03 19:23:03 +0200
committerBenoit Germain <benoit.germain@ubisoft.com>2024-05-03 19:23:03 +0200
commit2a2edc1071f314f65fdd9c3bf8af888921c32830 (patch)
tree94950f667517bca27665d771c9dac398d64ca308 /src
parent4995040204ca27b13ed4e52ad01d76111ae6b081 (diff)
downloadlanes-2a2edc1071f314f65fdd9c3bf8af888921c32830.tar.gz
lanes-2a2edc1071f314f65fdd9c3bf8af888921c32830.tar.bz2
lanes-2a2edc1071f314f65fdd9c3bf8af888921c32830.zip
Fix handling of error occuring during lane setup
Diffstat (limited to 'src')
-rw-r--r--src/lanes.cpp8
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();