Minor cleanup.
This commit is contained in:
parent
ed6bef6d24
commit
50b54599ef
@ -629,7 +629,6 @@ static int _tf_command_sandbox(const char* file, int argc, char* argv[])
|
||||
show_usage = true;
|
||||
break;
|
||||
case 'f':
|
||||
tf_printf("got -f %s\n", optarg);
|
||||
fd = atoi(optarg);
|
||||
break;
|
||||
}
|
||||
|
@ -122,10 +122,11 @@ static JSValue _taskstub_create(JSContext* context, JSValueConst this_val, int a
|
||||
char arg1[] = "sandbox";
|
||||
char* command_argv[] = { _executable, arg1, 0 };
|
||||
|
||||
tf_android_start_service_t* start_service = tf_task_get_android_start_service();
|
||||
JSValue result = JS_NULL;
|
||||
if (tf_task_get_one_proc(parent))
|
||||
if (tf_task_get_one_proc(parent) || start_service)
|
||||
{
|
||||
uv_os_sock_t fds[2];
|
||||
uv_os_sock_t fds[2] = { 0 };
|
||||
int pipe_result = uv_socketpair(SOCK_STREAM, 0, fds, 0, 0);
|
||||
if (pipe_result)
|
||||
{
|
||||
@ -133,7 +134,7 @@ static JSValue _taskstub_create(JSContext* context, JSValueConst this_val, int a
|
||||
}
|
||||
|
||||
uv_pipe_t* pipe = tf_packetstream_get_pipe(stub->_stream);
|
||||
memset(pipe, 0, sizeof(*pipe));
|
||||
*pipe = (uv_pipe_t) { 0 };
|
||||
pipe_result = uv_pipe_init(tf_task_get_loop(parent), pipe, 1);
|
||||
if (pipe_result != 0)
|
||||
{
|
||||
@ -145,41 +146,17 @@ static JSValue _taskstub_create(JSContext* context, JSValueConst this_val, int a
|
||||
tf_printf("uv_pipe_open failed: %s\n", uv_strerror(pipe_result));
|
||||
}
|
||||
|
||||
uv_thread_t* thread = tf_malloc(sizeof(uv_thread_t));
|
||||
uv_thread_create(thread, _tf_taskstub_run_sandbox_thread, (void*)(intptr_t)fds[1]);
|
||||
|
||||
tf_packetstream_set_on_receive(stub->_stream, tf_task_on_receive_packet, stub);
|
||||
tf_packetstream_start(stub->_stream);
|
||||
result = taskObject;
|
||||
if (start_service)
|
||||
{
|
||||
start_service(fds[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
tf_android_start_service_t* start_service = tf_task_get_android_start_service();
|
||||
if (start_service)
|
||||
{
|
||||
uv_os_sock_t fds[2];
|
||||
int socketpair_result = uv_socketpair(SOCK_STREAM, 0, fds, 0, 0);
|
||||
if (socketpair_result)
|
||||
{
|
||||
tf_printf("uv_socketpair: %s\n", uv_strerror(socketpair_result));
|
||||
/* XXX: This is a leak. */
|
||||
uv_thread_t* thread = tf_malloc(sizeof(uv_thread_t));
|
||||
uv_thread_create(thread, _tf_taskstub_run_sandbox_thread, (void*)(intptr_t)fds[1]);
|
||||
}
|
||||
|
||||
uv_pipe_t* pipe = tf_packetstream_get_pipe(stub->_stream);
|
||||
*pipe = (uv_pipe_t) { 0 };
|
||||
if (uv_pipe_init(tf_task_get_loop(parent), pipe, 1) != 0)
|
||||
{
|
||||
tf_printf("uv_pipe_init failed\n");
|
||||
}
|
||||
|
||||
int pipe_result = uv_pipe_open(pipe, fds[0]);
|
||||
if (pipe_result)
|
||||
{
|
||||
tf_printf("uv_pipe_open: %s\n", uv_strerror(pipe_result));
|
||||
}
|
||||
|
||||
start_service(fds[1]);
|
||||
|
||||
stub->_process.data = stub;
|
||||
tf_packetstream_set_on_receive(stub->_stream, tf_task_on_receive_packet, stub);
|
||||
tf_packetstream_start(stub->_stream);
|
||||
result = taskObject;
|
||||
@ -223,7 +200,6 @@ static JSValue _taskstub_create(JSContext* context, JSValueConst this_val, int a
|
||||
JS_FreeValue(context, taskObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
return JS_DupValue(context, result);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user