Multiple test fixes.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3874 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2022-05-21 00:06:01 +00:00
parent 7848b5e560
commit b688a89b66
3 changed files with 30 additions and 11 deletions

View File

@ -162,21 +162,20 @@ static void _file_write_write_callback(uv_fs_t* req)
static void _file_write_open_callback(uv_fs_t* req) static void _file_write_open_callback(uv_fs_t* req)
{ {
fs_req_t* fsreq = (fs_req_t*)req;
uv_fs_req_cleanup(req); uv_fs_req_cleanup(req);
tf_task_t* task = req->loop->data; tf_task_t* task = req->loop->data;
JSContext* context = tf_task_get_context(task); JSContext* context = tf_task_get_context(task);
promiseid_t promise = (promiseid_t)(intptr_t)req->data; promiseid_t promise = (promiseid_t)(intptr_t)req->data;
if (req->result >= 0) if (req->result >= 0)
{ {
size_t size = 0; uv_buf_t buf = { .base = fsreq->buffer, .len = fsreq->size };
memcpy(&size, req + 1, sizeof(size)); fsreq->file = req->result;
uv_buf_t buf = { .base = (char*)(req + 1) + sizeof(size), .len = size }; int result = uv_fs_write(req->loop, req, fsreq->file, &buf, 1, 0, _file_write_write_callback);
uv_file file = req->result;
int result = uv_fs_write(req->loop, req, file, &buf, 1, 0, _file_write_write_callback);
if (result < 0) if (result < 0)
{ {
tf_task_reject_promise(task, promise, JS_ThrowInternalError(context, uv_strerror(result))); tf_task_reject_promise(task, promise, JS_ThrowInternalError(context, uv_strerror(result)));
result = uv_fs_close(req->loop, req, file, _file_async_close_callback); result = uv_fs_close(req->loop, req, fsreq->file, _file_async_close_callback);
} }
} }
else else

View File

@ -591,6 +591,12 @@ void _socket_shutdownInternal(socket_t* socket, promiseid_t promise)
} }
void _socket_processTlsShutdown(socket_t* socket, promiseid_t promise) void _socket_processTlsShutdown(socket_t* socket, promiseid_t promise)
{
if (!socket->_tls)
{
_socket_shutdownInternal(socket, promise);
}
else
{ {
tf_tls_session_shutdown(socket->_tls); tf_tls_session_shutdown(socket->_tls);
if (!_socket_processSomeOutgoingTls(socket, promise, _socket_onTlsShutdown)) if (!_socket_processSomeOutgoingTls(socket, promise, _socket_onTlsShutdown))
@ -598,6 +604,7 @@ void _socket_processTlsShutdown(socket_t* socket, promiseid_t promise)
_socket_shutdownInternal(socket, promise); _socket_shutdownInternal(socket, promise);
} }
} }
}
void _socket_onTlsShutdown(uv_write_t* request, int status) void _socket_onTlsShutdown(uv_write_t* request, int status)
{ {

View File

@ -258,9 +258,22 @@ static void _taskstub_cleanup(tf_taskstub_t* stub)
static void _taskstub_finalizer(JSRuntime* runtime, JSValue value) static void _taskstub_finalizer(JSRuntime* runtime, JSValue value)
{ {
tf_taskstub_t* stub = JS_GetOpaque(value, _classId); tf_taskstub_t* stub = JS_GetOpaque(value, _classId);
JSContext* context = tf_task_get_context(stub->_owner);
if (!JS_IsUndefined(stub->_on_exit))
{
JS_FreeValue(context, stub->_on_exit);
stub->_on_exit = JS_UNDEFINED; stub->_on_exit = JS_UNDEFINED;
}
if (!JS_IsUndefined(stub->_on_error))
{
JS_FreeValue(context, stub->_on_error);
stub->_on_error = JS_UNDEFINED; stub->_on_error = JS_UNDEFINED;
}
if (!JS_IsUndefined(stub->_on_print))
{
JS_FreeValue(context, stub->_on_print);
stub->_on_print = JS_UNDEFINED; stub->_on_print = JS_UNDEFINED;
}
tf_packetstream_destroy(stub->_stream); tf_packetstream_destroy(stub->_stream);
stub->_stream = NULL; stub->_stream = NULL;
stub->_finalized = true; stub->_finalized = true;