Address some lifetime issues in the single-process case.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4565 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
56
src/task.c
56
src/task.c
@ -1118,7 +1118,16 @@ void tf_task_on_receive_packet(int packetType, const char* begin, size_t length,
|
||||
}
|
||||
break;
|
||||
case kKill:
|
||||
exit(1);
|
||||
if (to->_one_proc)
|
||||
{
|
||||
to->_killed = true;
|
||||
tf_packetstream_close(tf_taskstub_get_stream(from));
|
||||
uv_stop(&to->_loop);
|
||||
}
|
||||
else
|
||||
{
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case kSetImports:
|
||||
{
|
||||
@ -1752,7 +1761,7 @@ void tf_task_run(tf_task_t* task)
|
||||
do
|
||||
{
|
||||
uv_run(&task->_loop, UV_RUN_DEFAULT);
|
||||
} while (_tf_task_run_jobs(task));
|
||||
} while (!task->_killed && _tf_task_run_jobs(task));
|
||||
}
|
||||
|
||||
bool tf_task_get_one_proc(tf_task_t* task)
|
||||
@ -1787,24 +1796,6 @@ static void _tf_task_on_handle_close(uv_handle_t* handle)
|
||||
|
||||
void tf_task_destroy(tf_task_t* task)
|
||||
{
|
||||
for (int i = 0; i < task->_import_count; i++)
|
||||
{
|
||||
JS_FreeValue(task->_context, task->_imports[i]->_function);
|
||||
tf_free(task->_imports[i]);
|
||||
}
|
||||
tf_free(task->_imports);
|
||||
task->_imports = NULL;
|
||||
task->_import_count = 0;
|
||||
|
||||
for (int i = 0; i < task->_export_count; i++)
|
||||
{
|
||||
JS_FreeValue(task->_context, task->_exports[i]->_function);
|
||||
tf_free(task->_exports[i]);
|
||||
}
|
||||
tf_free(task->_exports);
|
||||
task->_exports = NULL;
|
||||
task->_export_count = 0;
|
||||
|
||||
while (task->_children)
|
||||
{
|
||||
task_child_node_t* node = task->_children;
|
||||
@ -1820,8 +1811,18 @@ void tf_task_destroy(tf_task_t* task)
|
||||
{
|
||||
tf_task_reject_promise(task, task->_promises[task->_promise_count - 1].id, JS_NULL);
|
||||
}
|
||||
tf_free(task->_promises);
|
||||
task->_promises = NULL;
|
||||
|
||||
for (int i = 0; i < task->_export_count; i++)
|
||||
{
|
||||
JS_FreeValue(task->_context, task->_exports[i]->_function);
|
||||
}
|
||||
tf_free(task->_imports);
|
||||
tf_free(task->_exports);
|
||||
task->_imports = NULL;
|
||||
task->_exports = NULL;
|
||||
task->_import_count = 0;
|
||||
task->_export_count = 0;
|
||||
|
||||
JS_FreeValue(task->_context, task->_loadedFiles);
|
||||
|
||||
if (task->_ssb)
|
||||
@ -1831,6 +1832,17 @@ void tf_task_destroy(tf_task_t* task)
|
||||
JS_FreeContext(task->_context);
|
||||
JS_FreeRuntime(task->_runtime);
|
||||
|
||||
tf_free(task->_promises);
|
||||
task->_promises = NULL;
|
||||
|
||||
tf_free(task->_imports);
|
||||
task->_imports = NULL;
|
||||
task->_import_count = 0;
|
||||
|
||||
tf_free(task->_exports);
|
||||
task->_exports = NULL;
|
||||
task->_export_count = 0;
|
||||
|
||||
if (task->_db)
|
||||
{
|
||||
sqlite3_close(task->_db);
|
||||
|
Reference in New Issue
Block a user