From 5d5ff121f944a586bed64992a188bf7d35851754 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Sat, 21 Jan 2023 20:12:41 +0000 Subject: [PATCH] Socket leak on accept. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4144 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- core/httpd.js | 11 ++++------- src/socket.js.c | 1 + 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/core/httpd.js b/core/httpd.js index 97e58a78..ff54d608 100644 --- a/core/httpd.js +++ b/core/httpd.js @@ -180,13 +180,10 @@ function handleRequest(request, response) { if (handler) { try { - let promise = handler.invoke(request, response); - if (promise) { - promise.catch(function(error) { - response.reportError(error); - request.client.close(); - }); - } + Promise.resolve(handler.invoke(request, response)).catch(function(error) { + response.reportError(error); + request.client.close(); + }); } catch (error) { response.reportError(error); request.client.close(); diff --git a/src/socket.js.c b/src/socket.js.c index 6cccccf1..89c5ef16 100644 --- a/src/socket.js.c +++ b/src/socket.js.c @@ -605,6 +605,7 @@ JSValue _socket_accept(JSContext* context, JSValueConst this_val, int argc, JSVa } client->_connected = true; tf_task_resolve_promise(socket->_task, promise, client->_object); + JS_FreeValue(context, client->_object); } else {