I think that's all the leaks accounted for though not yet fixed.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4799 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2024-01-27 15:45:51 +00:00
parent 08b5ade8ec
commit 923d6f9835
7 changed files with 22 additions and 16 deletions

View File

@ -163,7 +163,7 @@ static JSValue _httpd_response_send(JSContext* context, JSValueConst this_val, i
return JS_UNDEFINED;
}
static void _httpd_close_callback(tf_http_request_t* request)
static void _httpd_websocket_close_callback(tf_http_request_t* request)
{
JSContext* context = request->context;
JSValue response_object = JS_MKPTR(JS_TAG_OBJECT, request->user_data);
@ -172,7 +172,9 @@ static void _httpd_close_callback(tf_http_request_t* request)
tf_util_report_error(context, response);
JS_FreeValue(context, response);
JS_FreeValue(context, on_close);
tf_http_request_release(request);
JS_SetPropertyStr(context, response_object, "onMessage", JS_UNDEFINED);
JS_SetPropertyStr(context, response_object, "onClose", JS_UNDEFINED);
JS_FreeValue(context, response_object);
}
static void _httpd_message_callback(tf_http_request_t* request, int op_code, const void* data, size_t size)
@ -217,6 +219,7 @@ static void _httpd_callback_internal(tf_http_request_t* request, bool is_websock
JS_SetPropertyStr(context, request_object, "client", client);
JSValue response_object = JS_NewObjectClass(context, _httpd_request_class_id);
/* The ref is owned by the JS object and will be released by the finalizer. */
tf_http_request_ref(request);
JS_SetOpaque(response_object, request);
JS_SetPropertyStr(context, response_object, "writeHead", JS_NewCFunction(context, _httpd_response_write_head, "writeHead", 2));
@ -318,15 +321,15 @@ static JSValue _httpd_websocket_upgrade(JSContext* context, JSValueConst this_va
tf_http_respond(request, 101, headers, headers_count, NULL, 0);
request->on_message = _httpd_message_callback;
request->on_close = _httpd_close_callback;
request->on_close = _httpd_websocket_close_callback;
request->context = context;
request->user_data = JS_VALUE_GET_PTR(JS_DupValue(context, this_val));
}
else
{
tf_http_respond(request, 400, NULL, 0, NULL, 0);
tf_http_request_release(request);
}
tf_http_request_unref(request);
return JS_UNDEFINED;
}
@ -385,7 +388,7 @@ static void _httpd_finalizer(JSRuntime* runtime, JSValue value)
static void _httpd_request_finalizer(JSRuntime* runtime, JSValue value)
{
tf_http_request_t* request = JS_GetOpaque(value, _httpd_request_class_id);
tf_http_request_release(request);
tf_http_request_unref(request);
}
static void _httpd_endpoint_trace(tf_http_request_t* request)