GeezerVison is showing github.com — quic: reduce boilerplate and other minor cleanups · nodejs/node@a31a8ee
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: doc/api/cli.md +1-10Lines changed: 1 addition & 10 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1822,16 +1822,6 @@ added: v21.2.0 | 1822 | 1822 |
| 1823 | 1823 | Disable exposition of [Navigator API][] on the global scope. | 1824 | 1824 |
| 1825 | | -### `--no-experimental-quic` | 1826 | | - | 1827 | | -<!-- YAML | 1828 | | -added: REPLACEME | 1829 | | ---> | 1830 | | - | 1831 | | -> Stability: 1.1 - Active Development | 1832 | | -
| 1833 | | -Use this flag to disable QUIC. | 1834 | | - | 1835 | 1825 | ### `--no-experimental-repl-await` | 1836 | 1826 |
| 1837 | 1827 | <!-- YAML | @@ -3499,6 +3489,7 @@ one is included in the list below. | 3499 | 3489 | * `--experimental-loader` | 3500 | 3490 | * `--experimental-modules` | 3501 | 3491 | * `--experimental-print-required-tla` | | 3492 | +* `--experimental-quic` | 3502 | 3493 | * `--experimental-require-module` | 3503 | 3494 | * `--experimental-shadow-realm` | 3504 | 3495 | * `--experimental-specifier-resolution` | |
Collapse file Copy file name to clipboardExpand all lines: doc/node.1 -3Lines changed: 0 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -229,9 +229,6 @@ flag is no longer required as WASI is enabled by default. | 229 | 229 | .It Fl -experimental-quic | 230 | 230 | Enable the experimental QUIC support. | 231 | 231 | . | 232 | | -.It Fl -no-experimental-quic | 233 | | -Disable the experimental QUIC support. | 234 | | -. | 235 | 232 | .It Fl -experimental-inspector-network-resource | 236 | 233 | Enable experimental support for inspector network resources. | 237 | 234 | . | |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/quic/quic.js +7-4Lines changed: 7 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -15,11 +15,14 @@ const { | 15 | 15 | Uint8Array, | 16 | 16 | } = primordials; | 17 | 17 |
| 18 | | -// QUIC requires that Node.js be compiled with crypto support. | 19 | 18 | const { | 20 | | - assertCrypto, | 21 | | -} = require('internal/util'); | 22 | | -assertCrypto(); | | 19 | + getOptionValue, | | 20 | +} = require('internal/options'); | | 21 | + | | 22 | +// QUIC requires that Node.js be compiled with crypto support. | | 23 | +if (!process.features.quic || !getOptionValue('--experimental-quic')) { | | 24 | + return; | | 25 | +} | 23 | 26 |
| 24 | 27 | const { inspect } = require('internal/util/inspect'); | 25 | 28 |
| |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/quic/state.js +8Lines changed: 8 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -10,6 +10,14 @@ const { | 10 | 10 | JSONStringify, | 11 | 11 | } = primordials; | 12 | 12 |
| | 13 | +const { | | 14 | + getOptionValue, | | 15 | +} = require('internal/options'); | | 16 | + | | 17 | +if (!process.features.quic || !getOptionValue('--experimental-quic')) { | | 18 | + return; | | 19 | +} | | 20 | + | 13 | 21 | const { | 14 | 22 | codes: { | 15 | 23 | ERR_ILLEGAL_CONSTRUCTOR, | |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/quic/stats.js +8Lines changed: 8 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 5 | 5 | JSONStringify, | 6 | 6 | } = primordials; | 7 | 7 |
| | 8 | +const { | | 9 | + getOptionValue, | | 10 | +} = require('internal/options'); | | 11 | + | | 12 | +if (!process.features.quic || !getOptionValue('--experimental-quic')) { | | 13 | + return; | | 14 | +} | | 15 | + | 8 | 16 | const { | 9 | 17 | isArrayBuffer, | 10 | 18 | } = require('util/types'); | |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/quic/symbols.js +8Lines changed: 8 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 4 | 4 | Symbol, | 5 | 5 | } = primordials; | 6 | 6 |
| | 7 | +const { | | 8 | + getOptionValue, | | 9 | +} = require('internal/options'); | | 10 | + | | 11 | +if (!process.features.quic || !getOptionValue('--experimental-quic')) { | | 12 | + return; | | 13 | +} | | 14 | + | 7 | 15 | const { | 8 | 16 | customInspectSymbol: kInspect, | 9 | 17 | } = require('internal/util'); | |
Collapse file Copy file name to clipboardExpand all lines: src/node_metadata.h +2-9Lines changed: 2 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -60,6 +60,8 @@ namespace node { | 60 | 60 | V(simdutf) \ | 61 | 61 | V(ada) \ | 62 | 62 | V(nbytes) \ | | 63 | + V(ngtcp2) \ | | 64 | + V(nghttp3) \ | 63 | 65 | NODE_VERSIONS_KEY_AMARO(V) \ | 64 | 66 | NODE_VERSIONS_KEY_UNDICI(V) \ | 65 | 67 | V(merve) | @@ -80,14 +82,6 @@ namespace node { | 80 | 82 | #define NODE_VERSIONS_KEY_INTL(V) | 81 | 83 | #endif // NODE_HAVE_I18N_SUPPORT | 82 | 84 |
| 83 | | -#ifndef OPENSSL_NO_QUIC | 84 | | -#define NODE_VERSIONS_KEY_QUIC(V) \ | 85 | | - V(ngtcp2) \ | 86 | | - V(nghttp3) | 87 | | -#else | 88 | | -#define NODE_VERSIONS_KEY_QUIC(V) | 89 | | -#endif | 90 | | - | 91 | 85 | #if HAVE_SQLITE | 92 | 86 | #define NODE_VERSIONS_KEY_SQLITE(V) V(sqlite) | 93 | 87 | #else | @@ -98,7 +92,6 @@ namespace node { | 98 | 92 | NODE_VERSIONS_KEYS_BASE(V) \ | 99 | 93 | NODE_VERSIONS_KEY_CRYPTO(V) \ | 100 | 94 | NODE_VERSIONS_KEY_INTL(V) \ | 101 | | - NODE_VERSIONS_KEY_QUIC(V) \ | 102 | 95 | NODE_VERSIONS_KEY_SQLITE(V) | 103 | 96 |
| 104 | 97 | #define V(key) +1 | |
Collapse file Copy file name to clipboardExpand all lines: src/node_options.cc +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -565,10 +565,11 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() { | 565 | 565 | kAllowedInEnvvar, | 566 | 566 | true); | 567 | 567 | AddOption("--experimental-quic", | 568 | | - "" /* undocumented until its development */, | 569 | 568 | #ifndef OPENSSL_NO_QUIC | | 569 | + "experimental QUIC support", | 570 | 570 | &EnvironmentOptions::experimental_quic, | 571 | 571 | #else | | 572 | + "" /* undocumented when no-op */, | 572 | 573 | NoOp{}, | 573 | 574 | #endif | 574 | 575 | kAllowedInEnvvar); | |
Collapse file Copy file name to clipboardExpand all lines: src/quic/bindingdata.cc +3-4Lines changed: 3 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 17 | 17 | namespace node { | 18 | 18 |
| 19 | 19 | using v8::Function; | 20 | | -using v8::FunctionCallbackInfo; | 21 | 20 | using v8::FunctionTemplate; | 22 | 21 | using v8::Local; | 23 | 22 | using v8::Object; | @@ -144,7 +143,7 @@ QUIC_JS_CALLBACKS(V) | 144 | 143 |
| 145 | 144 | #undef V | 146 | 145 |
| 147 | | -void BindingData::SetCallbacks(const FunctionCallbackInfo<Value>& args) { | | 146 | +JS_METHOD_IMPL(BindingData::SetCallbacks) { | 148 | 147 | auto env = Environment::GetCurrent(args); | 149 | 148 | auto isolate = env->isolate(); | 150 | 149 | auto& state = Get(env); | @@ -166,7 +165,7 @@ void BindingData::SetCallbacks(const FunctionCallbackInfo<Value>& args) { | 166 | 165 | #undef V | 167 | 166 | } | 168 | 167 |
| 169 | | -void BindingData::FlushPacketFreelist(const FunctionCallbackInfo<Value>& args) { | | 168 | +JS_METHOD_IMPL(BindingData::FlushPacketFreelist) { | 170 | 169 | auto env = Environment::GetCurrent(args); | 171 | 170 | auto& state = Get(env); | 172 | 171 | state.packet_freelist.clear(); | @@ -217,7 +216,7 @@ CallbackScopeBase::~CallbackScopeBase() { | 217 | 216 | } | 218 | 217 | } | 219 | 218 |
| 220 | | -void IllegalConstructor(const FunctionCallbackInfo<Value>& args) { | | 219 | +JS_METHOD_IMPL(IllegalConstructor) { | 221 | 220 | THROW_ERR_ILLEGAL_CONSTRUCTOR(Environment::GetCurrent(args)); | 222 | 221 | } | 223 | 222 |
| |
Collapse file Copy file name to clipboardExpand all lines: src/quic/bindingdata.h +5-6Lines changed: 5 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -167,16 +167,15 @@ class BindingData final | 167 | 167 |
| 168 | 168 | // Installs the set of JavaScript callback functions that are used to | 169 | 169 | // bridge out to the JS API. | 170 | | - static void SetCallbacks(const v8::FunctionCallbackInfo<v8::Value>& args); | | 170 | + JS_METHOD(SetCallbacks); | | 171 | + | | 172 | + // Purge the packet free list to free up memory. | | 173 | + JS_METHOD(FlushPacketFreelist); | 171 | 174 |
| 172 | 175 | std::vector<BaseObjectPtr<BaseObject>> packet_freelist; | 173 | 176 |
| 174 | 177 | std::unordered_map<Endpoint*, BaseObjectPtr<BaseObject>> listening_endpoints; | 175 | 178 |
| 176 | | - // Purge the packet free list to free up memory. | 177 | | - static void FlushPacketFreelist( | 178 | | - const v8::FunctionCallbackInfo<v8::Value>& args); | 179 | | - | 180 | 179 | bool in_ngtcp2_callback_scope = false; | 181 | 180 | bool in_nghttp3_callback_scope = false; | 182 | 181 | size_t current_ngtcp2_memory_ = 0; | @@ -223,7 +222,7 @@ class BindingData final | 223 | 222 | #undef V | 224 | 223 | }; | 225 | 224 |
| 226 | | -void IllegalConstructor(const v8::FunctionCallbackInfo<v8::Value>& args); | | 225 | +JS_METHOD_IMPL(IllegalConstructor); | 227 | 226 |
| 228 | 227 | // The ngtcp2 and nghttp3 callbacks have certain restrictions | 229 | 228 | // that forbid re-entry. We provide the following scopes for | |
|