Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2019-08-15 16:03:43 +0300
committerRich Trott <rtrott@gmail.com>2019-08-18 06:13:24 +0300
commit41637a530efb761c713a36f1465cc5ea9b976900 (patch)
tree0ced85c845a70006bb57ce8a93c807e44666680d /src/node_http2.cc
parent5dee17bb3c7d7b6fcec0d3ac02e0348c558a206b (diff)
http2: remove callback-based padding
This option is not useful in practice, as mentioned in comments and the documentation, because the overhead of calling into JS makes it unreasonably expensive. PR-URL: https://github.com/nodejs/node/pull/29144 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'src/node_http2.cc')
-rw-r--r--src/node_http2.cc43
1 files changed, 3 insertions, 40 deletions
diff --git a/src/node_http2.cc b/src/node_http2.cc
index 38686dc7502..485d54880bd 100644
--- a/src/node_http2.cc
+++ b/src/node_http2.cc
@@ -840,32 +840,6 @@ ssize_t Http2Session::OnMaxFrameSizePadding(size_t frameLen,
return maxPayloadLen;
}
-// Used as one of the Padding Strategy functions. Uses a callback to JS land
-// to determine the amount of padding for the current frame. This option is
-// rather more expensive because of the JS boundary cross. It generally should
-// not be the preferred option.
-ssize_t Http2Session::OnCallbackPadding(size_t frameLen,
- size_t maxPayloadLen) {
- if (frameLen == 0) return 0;
- Debug(this, "using callback to determine padding");
- Isolate* isolate = env()->isolate();
- HandleScope handle_scope(isolate);
- Local<Context> context = env()->context();
- Context::Scope context_scope(context);
-
- AliasedUint32Array& buffer = env()->http2_state()->padding_buffer;
- buffer[PADDING_BUF_FRAME_LENGTH] = frameLen;
- buffer[PADDING_BUF_MAX_PAYLOAD_LENGTH] = maxPayloadLen;
- buffer[PADDING_BUF_RETURN_VALUE] = frameLen;
- MakeCallback(env()->http2session_on_select_padding_function(), 0, nullptr);
- uint32_t retval = buffer[PADDING_BUF_RETURN_VALUE];
- retval = std::min(retval, static_cast<uint32_t>(maxPayloadLen));
- retval = std::max(retval, static_cast<uint32_t>(frameLen));
- Debug(this, "using padding size %d", retval);
- return retval;
-}
-
-
// Write data received from the i/o stream to the underlying nghttp2_session.
// On each call to nghttp2_session_mem_recv, nghttp2 will begin calling the
// various callback functions. Each of these will typically result in a call
@@ -1251,9 +1225,6 @@ ssize_t Http2Session::OnSelectPadding(nghttp2_session* handle,
case PADDING_STRATEGY_ALIGNED:
padding = session->OnDWordAlignedPadding(padding, maxPayloadLen);
break;
- case PADDING_STRATEGY_CALLBACK:
- padding = session->OnCallbackPadding(padding, maxPayloadLen);
- break;
}
return padding;
}
@@ -3024,7 +2995,7 @@ void nghttp2_header::MemoryInfo(MemoryTracker* tracker) const {
void SetCallbackFunctions(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
- CHECK_EQ(args.Length(), 12);
+ CHECK_EQ(args.Length(), 11);
#define SET_FUNCTION(arg, name) \
CHECK(args[arg]->IsFunction()); \
@@ -3039,9 +3010,8 @@ void SetCallbackFunctions(const FunctionCallbackInfo<Value>& args) {
SET_FUNCTION(6, goaway_data)
SET_FUNCTION(7, altsvc)
SET_FUNCTION(8, origin)
- SET_FUNCTION(9, select_padding)
- SET_FUNCTION(10, stream_trailers)
- SET_FUNCTION(11, stream_close)
+ SET_FUNCTION(9, stream_trailers)
+ SET_FUNCTION(10, stream_close)
#undef SET_FUNCTION
}
@@ -3062,9 +3032,6 @@ void Initialize(Local<Object> target,
FIXED_ONE_BYTE_STRING(isolate, (name)), \
(field)).FromJust()
- // Initialize the buffer used for padding callbacks
- SET_STATE_TYPEDARRAY(
- "paddingBuffer", state->padding_buffer.GetJSArray());
// Initialize the buffer used to store the session state
SET_STATE_TYPEDARRAY(
"sessionState", state->session_state_buffer.GetJSArray());
@@ -3083,10 +3050,6 @@ void Initialize(Local<Object> target,
env->set_http2_state(std::move(state));
- NODE_DEFINE_CONSTANT(target, PADDING_BUF_FRAME_LENGTH);
- NODE_DEFINE_CONSTANT(target, PADDING_BUF_MAX_PAYLOAD_LENGTH);
- NODE_DEFINE_CONSTANT(target, PADDING_BUF_RETURN_VALUE);
-
NODE_DEFINE_CONSTANT(target, kBitfield);
NODE_DEFINE_CONSTANT(target, kSessionPriorityListenerCount);
NODE_DEFINE_CONSTANT(target, kSessionFrameErrorListenerCount);