Skip to content

Commit

Permalink
quic: cleanups in JS API
Browse files Browse the repository at this point in the history
PR-URL: #34137
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: David Carlier <devnexen@gmail.com>
  • Loading branch information
jasnell committed Jul 1, 2020
1 parent e20beaf commit 73a51bb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
19 changes: 5 additions & 14 deletions lib/internal/quic/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,19 +247,11 @@ let warnedVerifyHostnameIdentity = false;

assert(process.versions.ngtcp2 !== undefined);

// Called by the C++ internals when the socket is closed.
// When this is called, the only thing left to do is destroy
// the QuicSocket instance.
function onSocketClose() {
this[owner_symbol].destroy();
}

// Called by the C++ internals when an error occurs on the socket.
// When this is called, the only thing left to do is destroy
// the QuicSocket instance with an error.
// TODO(@jasnell): Should consolidate this with onSocketClose
function onSocketError(err) {
this[owner_symbol].destroy(errnoException(err));
// Called by the C++ internals when the QuicSocket is closed with
// or without an error. The only thing left to do is destroy the
// QuicSocket instance.
function onSocketClose(err) {
this[owner_symbol].destroy(err != null ? errnoException(err) : undefined);
}

// Called by the C++ internals when the server busy state of
Expand Down Expand Up @@ -579,7 +571,6 @@ function onStreamBlocked() {
// Register the callbacks with the QUIC internal binding.
setCallbacks({
onSocketClose,
onSocketError,
onSocketServerBusy,
onSessionReady,
onSessionCert,
Expand Down
1 change: 0 additions & 1 deletion src/quic/node_quic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ void QuicSetCallbacks(const FunctionCallbackInfo<Value>& args) {
} while (0)

SETFUNCTION("onSocketClose", socket_close);
SETFUNCTION("onSocketError", socket_error);
SETFUNCTION("onSessionReady", session_ready);
SETFUNCTION("onSessionCert", session_cert);
SETFUNCTION("onSessionClientHello", session_client_hello);
Expand Down
2 changes: 1 addition & 1 deletion src/quic/node_quic_socket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void JSQuicSocketListener::OnError(ssize_t code) {
HandleScope scope(env->isolate());
Context::Scope context_scope(env->context());
Local<Value> arg = Number::New(env->isolate(), static_cast<double>(code));
socket()->MakeCallback(env->quic_on_socket_error_function(), 1, &arg);
socket()->MakeCallback(env->quic_on_socket_close_function(), 1, &arg);
}

void JSQuicSocketListener::OnSessionReady(BaseObjectPtr<QuicSession> session) {
Expand Down

0 comments on commit 73a51bb

Please sign in to comment.