fix(task): release reservation safely on early cancellation
This commit is contained in:
parent
ad90295e0d
commit
cba1da075d
1 changed files with 16 additions and 0 deletions
16
src/task.c
16
src/task.c
|
|
@ -141,8 +141,16 @@ lardon3d_task_start(
|
||||||
task->has_contract = true;
|
task->has_contract = true;
|
||||||
(void)clock_gettime(CLOCK_REALTIME, &task->started_at);
|
(void)clock_gettime(CLOCK_REALTIME, &task->started_at);
|
||||||
if (task->cancel_requested) {
|
if (task->cancel_requested) {
|
||||||
|
Lardon3DResourceReservation *reservation_copy = task->current_reservation;
|
||||||
|
task->current_reservation = NULL;
|
||||||
finish_locked(task, TASK_CANCELLED, "Tâche annulée.");
|
finish_locked(task, TASK_CANCELLED, "Tâche annulée.");
|
||||||
(void)pthread_mutex_unlock(&task->mutex);
|
(void)pthread_mutex_unlock(&task->mutex);
|
||||||
|
if (reservation_copy) {
|
||||||
|
(void)lardon3d_resource_governor_release(
|
||||||
|
governor,
|
||||||
|
reservation_copy
|
||||||
|
);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
while (task->pause_requested && !task->cancel_requested) {
|
while (task->pause_requested && !task->cancel_requested) {
|
||||||
|
|
@ -152,8 +160,16 @@ lardon3d_task_start(
|
||||||
(void)pthread_cond_wait(&task->condition, &task->mutex);
|
(void)pthread_cond_wait(&task->condition, &task->mutex);
|
||||||
}
|
}
|
||||||
if (task->cancel_requested) {
|
if (task->cancel_requested) {
|
||||||
|
Lardon3DResourceReservation *reservation_copy = task->current_reservation;
|
||||||
|
task->current_reservation = NULL;
|
||||||
finish_locked(task, TASK_CANCELLED, "Tâche annulée.");
|
finish_locked(task, TASK_CANCELLED, "Tâche annulée.");
|
||||||
(void)pthread_mutex_unlock(&task->mutex);
|
(void)pthread_mutex_unlock(&task->mutex);
|
||||||
|
if (reservation_copy) {
|
||||||
|
(void)lardon3d_resource_governor_release(
|
||||||
|
governor,
|
||||||
|
reservation_copy
|
||||||
|
);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
task->state = TASK_RUNNING;
|
task->state = TASK_RUNNING;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue