diff --git a/src/node_http2.cc b/src/node_http2.cc index 568b59b5b4d722..4b29013636bb24 100644 --- a/src/node_http2.cc +++ b/src/node_http2.cc @@ -824,7 +824,7 @@ int Http2Session::DoWrite(WriteWrap* req_wrap, return 0; } -void Http2Session::AllocateSend(size_t recommended, uv_buf_t* buf) { +void Http2Session::AllocateSend(uv_buf_t* buf) { buf->base = stream_alloc(); buf->len = kAllocBufferSize; } diff --git a/src/node_http2.h b/src/node_http2.h index 3e90c49cd77b6b..e35c189ea68d86 100644 --- a/src/node_http2.h +++ b/src/node_http2.h @@ -331,7 +331,8 @@ class Http2Options { padding_strategy_type padding_strategy_ = PADDING_STRATEGY_NONE; }; -static const size_t kAllocBufferSize = 64 * 1024; +// This allows for 4 default-sized frames with their frame headers +static const size_t kAllocBufferSize = 4 * (16384 + 9); typedef uint32_t(*get_setting)(nghttp2_session* session, nghttp2_settings_id id); @@ -414,7 +415,7 @@ class Http2Session : public AsyncWrap, void OnFrameError(int32_t id, uint8_t type, int error_code) override; void OnTrailers(Nghttp2Stream* stream, const SubmitTrailers& submit_trailers) override; - void AllocateSend(size_t recommended, uv_buf_t* buf) override; + void AllocateSend(uv_buf_t* buf) override; int DoWrite(WriteWrap* w, uv_buf_t* bufs, size_t count, uv_stream_t* send_handle) override; diff --git a/src/node_http2_core-inl.h b/src/node_http2_core-inl.h index 9735e565b2f0e2..5f6016a510e136 100644 --- a/src/node_http2_core-inl.h +++ b/src/node_http2_core-inl.h @@ -490,7 +490,7 @@ inline void Nghttp2Session::SendPendingData() { return; uv_buf_t dest; - AllocateSend(SEND_BUFFER_RECOMMENDED_SIZE, &dest); + AllocateSend(&dest); size_t destLength = 0; // amount of data stored in dest size_t destRemaining = dest.len; // amount space remaining in dest size_t destOffset = 0; // current write offset of dest diff --git a/src/node_http2_core.h b/src/node_http2_core.h index bb536f1159d90e..a7808ea0492256 100644 --- a/src/node_http2_core.h +++ b/src/node_http2_core.h @@ -42,7 +42,6 @@ class Nghttp2Stream; struct nghttp2_stream_write_t; #define MAX_BUFFER_COUNT 16 -#define SEND_BUFFER_RECOMMENDED_SIZE 4096 enum nghttp2_session_type { NGHTTP2_SESSION_SERVER, @@ -178,7 +177,7 @@ class Nghttp2Session { virtual ssize_t GetPadding(size_t frameLength, size_t maxFrameLength) { return 0; } virtual void OnFreeSession() {} - virtual void AllocateSend(size_t suggested_size, uv_buf_t* buf) = 0; + virtual void AllocateSend(uv_buf_t* buf) = 0; virtual bool HasGetPaddingCallback() { return false; }