Skip to content

Commit

Permalink
fix<cfored>: Fix crun/calloc fail when cancel pending task by ctrl c
Browse files Browse the repository at this point in the history
Signed-off-by: Li Junlin <[email protected]>
  • Loading branch information
L-Xiafeng committed Dec 3, 2024
1 parent f54b84c commit 2be98b0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/CraneCtld/TaskScheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1466,11 +1466,17 @@ void TaskScheduler::CleanCancelQueueCb_() {

if (task->type == crane::grpc::Interactive) {
auto& meta = std::get<InteractiveMetaInTask>(task->meta);
// Cancel request may come from crun/calloc
// Cancel request may not come from crun/calloc, ask them to exit
if (!meta.has_been_cancelled_on_front_end) {
meta.has_been_cancelled_on_front_end = true;
g_thread_pool->detach_task([cb = meta.cb_task_cancel,
task_id = task->TaskId()] { cb(task_id); });
} else {
// Cancel request from crun/calloc, reply CompletionAck
g_thread_pool->detach_task(
[cb = meta.cb_task_completed, task_id = task->TaskId()] {
cb(task_id, true);
});
}
}
}
Expand Down

0 comments on commit 2be98b0

Please sign in to comment.