From e2af3702c2ca553a87b14dc28869a8994f66d2df Mon Sep 17 00:00:00 2001 From: Darshan Sen Date: Sat, 13 Nov 2021 12:50:03 +0530 Subject: [PATCH] Revert "lib: use helper for readability" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 937bbc5571073d1fbeffd2d9e18949b3b4dcf09b. PR-URL: https://github.com/nodejs/node/pull/40741 Fixes: https://github.com/nodejs/node/issues/40693 Reviewed-By: Stephen Belanger Reviewed-By: Gerhard Stöbich Reviewed-By: Benjamin Gruenbaum --- lib/internal/js_stream_socket.js | 37 +++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/lib/internal/js_stream_socket.js b/lib/internal/js_stream_socket.js index bd902412564ceb..fd1294ec9764f9 100644 --- a/lib/internal/js_stream_socket.js +++ b/lib/internal/js_stream_socket.js @@ -22,41 +22,52 @@ const kCurrentWriteRequest = Symbol('kCurrentWriteRequest'); const kCurrentShutdownRequest = Symbol('kCurrentShutdownRequest'); const kPendingShutdownRequest = Symbol('kPendingShutdownRequest'); -function checkReusedHandle(self) { - let socket = self[owner_symbol]; +function isClosing() { + let socket = this[owner_symbol]; - if (socket.constructor.name === 'ReusedHandle') + if (socket.constructor.name === 'ReusedHandle') { socket = socket.handle; - - return socket; -} - -function isClosing() { - const socket = checkReusedHandle(this); + } return socket.isClosing(); } function onreadstart() { - const socket = checkReusedHandle(this); + let socket = this[owner_symbol]; + + if (socket.constructor.name === 'ReusedHandle') { + socket = socket.handle; + } return socket.readStart(); } function onreadstop() { - const socket = checkReusedHandle(this); + let socket = this[owner_symbol]; + + if (socket.constructor.name === 'ReusedHandle') { + socket = socket.handle; + } return socket.readStop(); } function onshutdown(req) { - const socket = checkReusedHandle(this); + let socket = this[owner_symbol]; + + if (socket.constructor.name === 'ReusedHandle') { + socket = socket.handle; + } return socket.doShutdown(req); } function onwrite(req, bufs) { - const socket = checkReusedHandle(this); + let socket = this[owner_symbol]; + + if (socket.constructor.name === 'ReusedHandle') { + socket = socket.handle; + } return socket.doWrite(req, bufs); }