Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b91a934

Browse filesBrowse files
jasnelladuh95
authored andcommitted
quic: update more of the quic to the new compile guard
Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: #59342 Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
1 parent ca0080c commit b91a934
Copy full SHA for b91a934

21 files changed

+240-146Lines changed: 240 additions & 146 deletions
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎node.gyp‎

Copy file name to clipboardExpand all lines: node.gyp
+15-14Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,15 @@
192192
'src/udp_wrap.cc',
193193
'src/util.cc',
194194
'src/uv.cc',
195+
'src/quic/bindingdata.cc',
195196
'src/quic/cid.cc',
196197
'src/quic/data.cc',
198+
'src/quic/logstream.cc',
199+
'src/quic/packet.cc',
200+
'src/quic/preferredaddress.cc',
201+
'src/quic/sessionticket.cc',
202+
'src/quic/tokens.cc',
203+
# 'src/quic/transportparams.cc',
197204
# headers to make for a more pleasant IDE experience
198205
'src/aliased_buffer.h',
199206
'src/aliased_buffer-inl.h',
@@ -331,9 +338,16 @@
331338
'src/udp_wrap.h',
332339
'src/util.h',
333340
'src/util-inl.h',
341+
'src/quic/bindingdata.h',
334342
'src/quic/cid.h',
335343
'src/quic/data.h',
336344
'src/quic/defs.h',
345+
'src/quic/logstream.h',
346+
'src/quic/packet.h',
347+
'src/quic/preferredaddress.h',
348+
'src/quic/sessionticket.h',
349+
'src/quic/tokens.h',
350+
# 'src/quic/transportparams.h',
337351
'src/quic/guard.h',
338352
],
339353
'node_crypto_sources': [
@@ -398,31 +412,17 @@
398412
],
399413
'node_quic_sources': [
400414
'src/quic/application.cc',
401-
'src/quic/bindingdata.cc',
402415
'src/quic/endpoint.cc',
403416
'src/quic/http3.cc',
404-
'src/quic/logstream.cc',
405-
'src/quic/packet.cc',
406-
'src/quic/preferredaddress.cc',
407417
'src/quic/session.cc',
408-
'src/quic/sessionticket.cc',
409418
'src/quic/streams.cc',
410419
'src/quic/tlscontext.cc',
411-
'src/quic/tokens.cc',
412-
'src/quic/transportparams.cc',
413420
'src/quic/application.h',
414-
'src/quic/bindingdata.h',
415421
'src/quic/endpoint.h',
416422
'src/quic/http3.h',
417-
'src/quic/logstream.h',
418-
'src/quic/packet.h',
419-
'src/quic/preferredaddress.h',
420423
'src/quic/session.h',
421-
'src/quic/sessionticket.h',
422424
'src/quic/streams.h',
423425
'src/quic/tlscontext.h',
424-
'src/quic/tokens.h',
425-
'src/quic/transportparams.h',
426426
'src/quic/quic.cc',
427427
],
428428
'node_cctest_openssl_sources': [
@@ -431,6 +431,7 @@
431431
'test/cctest/test_node_crypto_env.cc',
432432
'test/cctest/test_quic_cid.cc',
433433
'test/cctest/test_quic_error.cc',
434+
'test/cctest/test_quic_preferredaddress.cc',
434435
'test/cctest/test_quic_tokens.cc',
435436
],
436437
'node_cctest_inspector_sources': [
Collapse file

‎src/quic/application.cc‎

Copy file name to clipboardExpand all lines: src/quic/application.cc
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ void Session::Application::SendPendingData() {
290290
// The stream_data is the next block of data from the application stream.
291291
if (GetStreamData(&stream_data) < 0) {
292292
Debug(session_, "Application failed to get stream data");
293-
packet->Done(UV_ECANCELED);
293+
packet->CancelPacket();
294294
session_->SetLastError(QuicError::ForNgtcp2Error(NGTCP2_ERR_INTERNAL));
295295
return session_->Close(CloseMethod::SILENT);
296296
}
@@ -357,7 +357,7 @@ void Session::Application::SendPendingData() {
357357
if (ndatalen >= 0 && !StreamCommit(&stream_data, ndatalen)) {
358358
Debug(session_,
359359
"Failed to commit stream data while writing packets");
360-
packet->Done(UV_ECANCELED);
360+
packet->CancelPacket();;
361361
session_->SetLastError(
362362
QuicError::ForNgtcp2Error(NGTCP2_ERR_INTERNAL));
363363
return session_->Close(CloseMethod::SILENT);
@@ -371,11 +371,11 @@ void Session::Application::SendPendingData() {
371371
Debug(session_,
372372
"Application encountered error while writing packet: %s",
373373
ngtcp2_strerror(nwrite));
374-
packet->Done(UV_ECANCELED);
374+
packet->CancelPacket();
375375
session_->SetLastError(QuicError::ForNgtcp2Error(nwrite));
376376
return session_->Close(CloseMethod::SILENT);
377377
} else if (ndatalen >= 0 && !StreamCommit(&stream_data, ndatalen)) {
378-
packet->Done(UV_ECANCELED);
378+
packet->CancelPacket();
379379
session_->SetLastError(QuicError::ForNgtcp2Error(NGTCP2_ERR_INTERNAL));
380380
return session_->Close(CloseMethod::SILENT);
381381
}
@@ -394,7 +394,7 @@ void Session::Application::SendPendingData() {
394394
packet->Truncate(datalen);
395395
session_->Send(packet, path);
396396
} else {
397-
packet->Done(UV_ECANCELED);
397+
packet->CancelPacket();
398398
}
399399

400400
return;
Collapse file

‎src/quic/bindingdata.cc‎

Copy file name to clipboardExpand all lines: src/quic/bindingdata.cc
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
#if HAVE_OPENSSL && NODE_OPENSSL_HAS_QUIC
1+
#if HAVE_OPENSSL
2+
#include "guard.h"
3+
#ifndef OPENSSL_NO_QUIC
24
#include "bindingdata.h"
35
#include <base_object-inl.h>
46
#include <env-inl.h>
@@ -49,10 +51,12 @@ void BindingData::CheckAllocatedSize(size_t previous_size) const {
4951
}
5052

5153
void BindingData::IncreaseAllocatedSize(size_t size) {
54+
CHECK_GE(current_ngtcp2_memory_ + size, current_ngtcp2_memory_);
5255
current_ngtcp2_memory_ += size;
5356
}
5457

5558
void BindingData::DecreaseAllocatedSize(size_t size) {
59+
CHECK_LE(current_ngtcp2_memory_ - size, current_ngtcp2_memory_);
5660
current_ngtcp2_memory_ -= size;
5761
}
5862

@@ -220,4 +224,5 @@ void IllegalConstructor(const FunctionCallbackInfo<Value>& args) {
220224
} // namespace quic
221225
} // namespace node
222226

223-
#endif // HAVE_OPENSSL && NODE_OPENSSL_HAS_QUIC
227+
#endif // OPENSSL_NO_QUIC
228+
#endif // HAVE_OPENSSL
Collapse file

‎src/quic/bindingdata.h‎

Copy file name to clipboardExpand all lines: src/quic/bindingdata.h
+15-15Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#pragma once
22

33
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
4-
#if HAVE_OPENSSL && NODE_OPENSSL_HAS_QUIC
54

65
#include <base_object.h>
76
#include <env.h>
@@ -26,32 +25,32 @@ class Packet;
2625
// The FunctionTemplates the BindingData will store for us.
2726
#define QUIC_CONSTRUCTORS(V) \
2827
V(endpoint) \
28+
V(http3application) \
2929
V(logstream) \
3030
V(packet) \
3131
V(session) \
3232
V(stream) \
33-
V(udp) \
34-
V(http3application)
33+
V(udp)
3534

3635
// The callbacks are persistent v8::Function references that are set in the
3736
// quic::BindingState used to communicate data and events back out to the JS
3837
// environment. They are set once from the JavaScript side when the
3938
// internalBinding('quic') is first loaded.
4039
#define QUIC_JS_CALLBACKS(V) \
4140
V(endpoint_close, EndpointClose) \
42-
V(session_new, SessionNew) \
4341
V(session_close, SessionClose) \
4442
V(session_datagram, SessionDatagram) \
4543
V(session_datagram_status, SessionDatagramStatus) \
4644
V(session_handshake, SessionHandshake) \
45+
V(session_new, SessionNew) \
46+
V(session_path_validation, SessionPathValidation) \
4747
V(session_ticket, SessionTicket) \
4848
V(session_version_negotiation, SessionVersionNegotiation) \
49-
V(session_path_validation, SessionPathValidation) \
49+
V(stream_blocked, StreamBlocked) \
5050
V(stream_close, StreamClose) \
5151
V(stream_created, StreamCreated) \
52-
V(stream_reset, StreamReset) \
5352
V(stream_headers, StreamHeaders) \
54-
V(stream_blocked, StreamBlocked) \
53+
V(stream_reset, StreamReset) \
5554
V(stream_trailers, StreamTrailers)
5655

5756
// The various JS strings the implementation uses.
@@ -64,10 +63,10 @@ class Packet;
6463
V(application_provider, "provider") \
6564
V(bbr, "bbr") \
6665
V(ca, "ca") \
67-
V(certs, "certs") \
6866
V(cc_algorithm, "cc") \
69-
V(crl, "crl") \
67+
V(certs, "certs") \
7068
V(ciphers, "ciphers") \
69+
V(crl, "crl") \
7170
V(cubic, "cubic") \
7271
V(disable_stateless_reset, "disableStatelessReset") \
7372
V(enable_connect_protocol, "enableConnectProtocol") \
@@ -114,8 +113,8 @@ class Packet;
114113
V(qpack_max_dtable_capacity, "qpackMaxDTableCapacity") \
115114
V(reject_unauthorized, "rejectUnauthorized") \
116115
V(reno, "reno") \
117-
V(retry_token_expiration, "retryTokenExpiration") \
118116
V(reset_token_secret, "resetTokenSecret") \
117+
V(retry_token_expiration, "retryTokenExpiration") \
119118
V(rx_loss, "rxDiagnosticLoss") \
120119
V(servername, "servername") \
121120
V(session, "Session") \
@@ -150,6 +149,9 @@ class BindingData final
150149
static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
151150

152151
static BindingData& Get(Environment* env);
152+
static inline BindingData& Get(Realm* realm) {
153+
return Get(realm->env());
154+
}
153155

154156
BindingData(Realm* realm, v8::Local<v8::Object> object);
155157
DISALLOW_COPY_AND_MOVE(BindingData)
@@ -179,6 +181,7 @@ class BindingData final
179181

180182
bool in_ngtcp2_callback_scope = false;
181183
bool in_nghttp3_callback_scope = false;
184+
size_t current_ngtcp2_memory_ = 0;
182185

183186
// The following set up various storage and accessors for common strings,
184187
// construction templates, and callbacks stored on the BindingData. These
@@ -205,8 +208,6 @@ class BindingData final
205208
QUIC_JS_CALLBACKS(V)
206209
#undef V
207210

208-
size_t current_ngtcp2_memory_ = 0;
209-
210211
#define V(name) v8::Global<v8::FunctionTemplate> name##_constructor_template_;
211212
QUIC_CONSTRUCTORS(V)
212213
#undef V
@@ -229,15 +230,15 @@ void IllegalConstructor(const v8::FunctionCallbackInfo<v8::Value>& args);
229230
// The ngtcp2 and nghttp3 callbacks have certain restrictions
230231
// that forbid re-entry. We provide the following scopes for
231232
// use in those to help protect against it.
232-
struct NgTcp2CallbackScope {
233+
struct NgTcp2CallbackScope final {
233234
Environment* env;
234235
explicit NgTcp2CallbackScope(Environment* env);
235236
DISALLOW_COPY_AND_MOVE(NgTcp2CallbackScope)
236237
~NgTcp2CallbackScope();
237238
static bool in_ngtcp2_callback(Environment* env);
238239
};
239240

240-
struct NgHttp3CallbackScope {
241+
struct NgHttp3CallbackScope final {
241242
Environment* env;
242243
explicit NgHttp3CallbackScope(Environment* env);
243244
DISALLOW_COPY_AND_MOVE(NgHttp3CallbackScope)
@@ -268,5 +269,4 @@ struct CallbackScope final : public CallbackScopeBase {
268269

269270
} // namespace node::quic
270271

271-
#endif // HAVE_OPENSSL && NODE_OPENSSL_HAS_QUIC
272272
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
Collapse file

‎src/quic/endpoint.cc‎

Copy file name to clipboardExpand all lines: src/quic/endpoint.cc
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -751,14 +751,14 @@ void Endpoint::Send(const BaseObjectPtr<Packet>& packet) {
751751
// dropped. This can happen to any type of packet. We use this only in
752752
// testing to test various reliability issues.
753753
if (is_diagnostic_packet_loss(options_.tx_loss)) [[unlikely]] {
754-
packet->Done(0);
754+
packet->Done();
755755
// Simulating tx packet loss
756756
return;
757757
}
758758
#endif // DEBUG
759759

760760
if (is_closed() || is_closing() || packet->length() == 0) {
761-
packet->Done(UV_ECANCELED);
761+
packet->CancelPacket();
762762
return;
763763
}
764764
Debug(this, "Sending %s", packet->ToString());
Collapse file

‎src/quic/logstream.cc‎

Copy file name to clipboardExpand all lines: src/quic/logstream.cc
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
#if HAVE_OPENSSL && NODE_OPENSSL_HAS_QUIC
2-
1+
#if HAVE_OPENSSL
2+
#include "guard.h"
3+
#ifndef OPENSSL_NO_QUIC
34
#include "logstream.h"
45
#include <async_wrap-inl.h>
56
#include <base_object-inl.h>
@@ -149,4 +150,5 @@ void LogStream::ensure_space(size_t amt) {
149150
} // namespace quic
150151
} // namespace node
151152

152-
#endif // HAVE_OPENSSL && NODE_OPENSSL_HAS_QUIC
153+
#endif // OPENSSL_NO_QUIC
154+
#endif // HAVE_OPENSSL
Collapse file

‎src/quic/logstream.h‎

Copy file name to clipboardExpand all lines: src/quic/logstream.h
+4-6Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
#pragma once
22

33
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
4-
#if HAVE_OPENSSL && NODE_OPENSSL_HAS_QUIC
54

65
#include <async_wrap.h>
76
#include <base_object.h>
87
#include <env.h>
98
#include <stream_base.h>
10-
#include <deque>
9+
#include <list>
1110

1211
namespace node::quic {
1312

1413
// The LogStream is a utility that the QUIC impl uses to publish both QLog
1514
// and Keylog diagnostic data (one instance for each).
16-
class LogStream : public AsyncWrap, public StreamBase {
15+
class LogStream final : public AsyncWrap, public StreamBase {
1716
public:
1817
static v8::Local<v8::FunctionTemplate> GetConstructorTemplate(
1918
Environment* env);
@@ -26,7 +25,7 @@ class LogStream : public AsyncWrap, public StreamBase {
2625

2726
LogStream(Environment* env, v8::Local<v8::Object> obj);
2827

29-
enum class EmitOption {
28+
enum class EmitOption : uint8_t {
3029
NONE,
3130
FIN,
3231
};
@@ -65,10 +64,10 @@ class LogStream : public AsyncWrap, public StreamBase {
6564
uv_buf_t buf;
6665
};
6766
size_t total_ = 0;
67+
std::list<Chunk> buffer_;
6868
bool fin_seen_ = false;
6969
bool ended_ = false;
7070
bool reading_ = false;
71-
std::deque<Chunk> buffer_;
7271

7372
// The value here is fairly arbitrary. Once we get everything
7473
// fully implemented and start working with this, we might
@@ -81,5 +80,4 @@ class LogStream : public AsyncWrap, public StreamBase {
8180

8281
} // namespace node::quic
8382

84-
#endif // HAVE_OPENSSL && NODE_OPENSSL_HAS_QUIC
8583
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.