mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-03 04:05:06 +00:00
Break all tasks on exit (#11026)
* Break all tasks on exit * null check in r_cons_context_break()
This commit is contained in:
parent
e08900b9bd
commit
cc3c87532a
@ -670,6 +670,9 @@ R_API bool r_cons_context_is_main() {
|
||||
}
|
||||
|
||||
R_API void r_cons_context_break(RConsContext *context) {
|
||||
if (!context) {
|
||||
return;
|
||||
}
|
||||
context->breaked = true;
|
||||
if (context->event_interrupt) {
|
||||
context->event_interrupt (context->event_interrupt_data);
|
||||
|
@ -2241,6 +2241,7 @@ R_API RCore *r_core_fini(RCore *c) {
|
||||
if (!c) {
|
||||
return NULL;
|
||||
}
|
||||
r_core_task_break_all (c);
|
||||
r_core_task_join (c, NULL, NULL);
|
||||
r_core_wait (c);
|
||||
/* TODO: it leaks as shit */
|
||||
|
@ -298,6 +298,11 @@ static int task_run(RCoreTask *task) {
|
||||
|
||||
task_wakeup (task);
|
||||
|
||||
if (task->cons_context && task->cons_context->breaked) {
|
||||
// breaked in R_CORE_TASK_STATE_BEFORE_START
|
||||
goto stillbirth;
|
||||
}
|
||||
|
||||
char *res_str;
|
||||
int res;
|
||||
if (task == task->core->main_task) {
|
||||
@ -317,6 +322,7 @@ static int task_run(RCoreTask *task) {
|
||||
eprintf ("\nTask %d finished\n", task->id);
|
||||
}
|
||||
|
||||
stillbirth:
|
||||
task_end (task);
|
||||
|
||||
if (task->cb) {
|
||||
@ -440,7 +446,7 @@ R_API void r_core_task_break(RCore *core, int id) {
|
||||
tasks_lock_enter (core, &old_sigset);
|
||||
RCoreTask *task = r_core_task_get (core, id);
|
||||
if (!task || task->state == R_CORE_TASK_STATE_DONE) {
|
||||
r_th_lock_leave (core->tasks_lock);
|
||||
tasks_lock_leave (core, &old_sigset);
|
||||
return;
|
||||
}
|
||||
if (task->cons_context) {
|
||||
@ -449,6 +455,19 @@ R_API void r_core_task_break(RCore *core, int id) {
|
||||
tasks_lock_leave (core, &old_sigset);
|
||||
}
|
||||
|
||||
R_API void r_core_task_break_all(RCore *core) {
|
||||
TASK_SIGSET_T old_sigset;
|
||||
tasks_lock_enter (core, &old_sigset);
|
||||
RCoreTask *task;
|
||||
RListIter *iter;
|
||||
r_list_foreach (core->tasks, iter, task) {
|
||||
if (task->state != R_CORE_TASK_STATE_DONE) {
|
||||
r_cons_context_break (task->cons_context);
|
||||
}
|
||||
}
|
||||
tasks_lock_leave (core, &old_sigset);
|
||||
}
|
||||
|
||||
R_API int r_core_task_del (RCore *core, int id) {
|
||||
RCoreTask *task;
|
||||
RListIter *iter;
|
||||
|
@ -758,6 +758,7 @@ R_API void r_core_task_continue(RCoreTask *t);
|
||||
R_API void r_core_task_sleep_begin(RCoreTask *task);
|
||||
R_API void r_core_task_sleep_end(RCoreTask *task);
|
||||
R_API void r_core_task_break(RCore *core, int id);
|
||||
R_API void r_core_task_break_all(RCore *core);
|
||||
R_API int r_core_task_del(RCore *core, int id);
|
||||
R_API void r_core_task_del_all_done(RCore *core);
|
||||
R_API RCoreTask *r_core_task_self(RCore *core);
|
||||
|
Loading…
x
Reference in New Issue
Block a user