Have we achieved clean shutdown?
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4841 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
28
src/task.c
28
src/task.c
@ -1418,6 +1418,7 @@ void tf_task_remove_child(tf_task_t* task, tf_taskstub_t* child)
|
||||
{
|
||||
task_child_node_t* node = *it;
|
||||
*it = node->next;
|
||||
JS_FreeValue(task->_context, tf_taskstub_get_task_object(child));
|
||||
tf_free(node);
|
||||
task->_child_count--;
|
||||
break;
|
||||
@ -1809,20 +1810,25 @@ static void _tf_task_on_handle_close(uv_handle_t* handle)
|
||||
handle->data = NULL;
|
||||
}
|
||||
|
||||
JSValue tf_taskstub_kill(tf_taskstub_t* stub);
|
||||
|
||||
void tf_task_destroy(tf_task_t* task)
|
||||
{
|
||||
while (task->_children)
|
||||
{
|
||||
task_child_node_t* node = task->_children;
|
||||
task->_children = node->next;
|
||||
tf_taskstub_destroy(node->stub);
|
||||
tf_free(node);
|
||||
for (task_child_node_t* node = task->_children; node; node = node->next)
|
||||
{
|
||||
JS_FreeValue(task->_context, tf_taskstub_kill(node->stub));
|
||||
|
||||
}
|
||||
uv_run(&task->_loop, UV_RUN_ONCE);
|
||||
}
|
||||
if (task->_parent)
|
||||
{
|
||||
tf_taskstub_destroy(task->_parent);
|
||||
tf_taskstub_t* parent = task->_parent;
|
||||
task->_parent = NULL;
|
||||
JS_RunGC(task->_runtime);
|
||||
tf_packetstream_close(tf_taskstub_get_stream(parent));
|
||||
JS_FreeValue(task->_context, tf_taskstub_get_task_object(parent));
|
||||
}
|
||||
while (task->_promise_count)
|
||||
{
|
||||
@ -1911,9 +1917,15 @@ void tf_task_destroy(tf_task_t* task)
|
||||
uv_run(&task->_loop, UV_RUN_ONCE);
|
||||
}
|
||||
|
||||
if (uv_loop_close(&task->_loop) != 0)
|
||||
int index = 0;
|
||||
while (uv_loop_close(&task->_loop) != 0)
|
||||
{
|
||||
uv_print_all_handles(&task->_loop, stdout);
|
||||
if (index++ > 0)
|
||||
{
|
||||
tf_printf("--\n");
|
||||
uv_print_all_handles(&task->_loop, stdout);
|
||||
}
|
||||
uv_run(&task->_loop, UV_RUN_ONCE);
|
||||
}
|
||||
if (task->_trace)
|
||||
{
|
||||
|
Reference in New Issue
Block a user