Skip to content
This repository was archived by the owner on Aug 11, 2020. It is now read-only.

Commit cda0d2c

Browse files
committed
quic: cleanup QuicSession code
- Do not create new `v8::Function` objects, both for performance and because it is unclear whether that leaks memory (Node.js issue 28988). - Do not put functions into the inline header that do not need to be there or that do not make sense as inline functions (in particular, callbacks that are provided to C libraries can not be realized as inline functions by the compiler). - Remove implicit/redundant `inline` qualifiers and add appropriate `const` qualifiers. - Remove unnecessary `this->` prefixes. - Return early for JS failures rather than accumulating them. - Minor stylistic changes. PR-URL: #126 Reviewed-By: Daniel Bevenius <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 54e9596 commit cda0d2c

File tree

4 files changed

+813
-848
lines changed

4 files changed

+813
-848
lines changed

lib/internal/quic/core.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,7 @@ function onSessionClose(code, family) {
262262
// some basic information about the ALPN, SNI, and Ciphers that are
263263
// being requested. It is only called if the 'clientHello' event is
264264
// listened for.
265-
function onSessionClientHello(alpn, servername, ciphers, callback) {
266-
callback = callback.bind(this);
265+
function onSessionClientHello(alpn, servername, ciphers) {
267266
this[owner_symbol][kClientHello](
268267
alpn,
269268
servername,
@@ -274,7 +273,7 @@ function onSessionClientHello(alpn, servername, ciphers, callback) {
274273
return;
275274
}
276275
try {
277-
callback(...args);
276+
this.onClientHelloDone(...args);
278277
} catch (err) {
279278
this[owner_symbol].destroy(err);
280279
}
@@ -283,10 +282,9 @@ function onSessionClientHello(alpn, servername, ciphers, callback) {
283282

284283
// This callback is only ever invoked for QuicServerSession instances,
285284
// and is used to trigger OCSP request processing when needed. The
286-
// user callback must invoke the callback function in order for the
285+
// user callback must invoke .onCertDone() in order for the
287286
// TLS handshake to continue.
288-
function onSessionCert(servername, callback) {
289-
callback = callback.bind(this);
287+
function onSessionCert(servername) {
290288
this[owner_symbol][kCert](servername, (err, context, ocspResponse) => {
291289
if (err) {
292290
this[owner_symbol].destroy(err);
@@ -311,7 +309,7 @@ function onSessionCert(servername, callback) {
311309
}
312310
}
313311
try {
314-
callback(context ? context.context : undefined, ocspResponse);
312+
this.onCertDone(context ? context.context : undefined, ocspResponse);
315313
} catch (err) {
316314
this[owner_symbol].destroy(err);
317315
}

0 commit comments

Comments
 (0)