Skip to content

Commit 73a51bb

Browse files
committed
quic: cleanups in JS API
PR-URL: #34137 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: David Carlier <devnexen@gmail.com>
1 parent e20beaf commit 73a51bb

File tree

3 files changed

+6
-16
lines changed

3 files changed

+6
-16
lines changed

lib/internal/quic/core.js

+5-14
Original file line numberDiff line numberDiff line change
@@ -247,19 +247,11 @@ let warnedVerifyHostnameIdentity = false;
247247

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

250-
// Called by the C++ internals when the socket is closed.
251-
// When this is called, the only thing left to do is destroy
252-
// the QuicSocket instance.
253-
function onSocketClose() {
254-
this[owner_symbol].destroy();
255-
}
256-
257-
// Called by the C++ internals when an error occurs on the socket.
258-
// When this is called, the only thing left to do is destroy
259-
// the QuicSocket instance with an error.
260-
// TODO(@jasnell): Should consolidate this with onSocketClose
261-
function onSocketError(err) {
262-
this[owner_symbol].destroy(errnoException(err));
250+
// Called by the C++ internals when the QuicSocket is closed with
251+
// or without an error. The only thing left to do is destroy the
252+
// QuicSocket instance.
253+
function onSocketClose(err) {
254+
this[owner_symbol].destroy(err != null ? errnoException(err) : undefined);
263255
}
264256

265257
// Called by the C++ internals when the server busy state of
@@ -579,7 +571,6 @@ function onStreamBlocked() {
579571
// Register the callbacks with the QUIC internal binding.
580572
setCallbacks({
581573
onSocketClose,
582-
onSocketError,
583574
onSocketServerBusy,
584575
onSessionReady,
585576
onSessionCert,

src/quic/node_quic.cc

-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ void QuicSetCallbacks(const FunctionCallbackInfo<Value>& args) {
5555
} while (0)
5656

5757
SETFUNCTION("onSocketClose", socket_close);
58-
SETFUNCTION("onSocketError", socket_error);
5958
SETFUNCTION("onSessionReady", session_ready);
6059
SETFUNCTION("onSessionCert", session_cert);
6160
SETFUNCTION("onSessionClientHello", session_client_hello);

src/quic/node_quic_socket.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ void JSQuicSocketListener::OnError(ssize_t code) {
137137
HandleScope scope(env->isolate());
138138
Context::Scope context_scope(env->context());
139139
Local<Value> arg = Number::New(env->isolate(), static_cast<double>(code));
140-
socket()->MakeCallback(env->quic_on_socket_error_function(), 1, &arg);
140+
socket()->MakeCallback(env->quic_on_socket_close_function(), 1, &arg);
141141
}
142142

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

0 commit comments

Comments
 (0)