Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
quic: cleanups in JS API
  • Loading branch information
jasnell committed Jun 30, 2020
commit a1b9e767f95849681f041a716a3b6ced870ae7c6
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