summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJames M Snell <jasnell@gmail.com>2018-01-03 11:15:57 -0800
committerJames M Snell <jasnell@gmail.com>2018-01-05 12:35:33 -0800
commit882e7ef354fd1d11f87c96648fd4b81613d788af (patch)
tree8ccf758eaaee0b18e9dea55f54c979ba04898fa4 /lib
parentfeaf6ac3dc923ed7b2fcaa3d44c62bf90674a128 (diff)
downloadandroid-node-v8-882e7ef354fd1d11f87c96648fd4b81613d788af.tar.gz
android-node-v8-882e7ef354fd1d11f87c96648fd4b81613d788af.tar.bz2
android-node-v8-882e7ef354fd1d11f87c96648fd4b81613d788af.zip
http2: implement maxSessionMemory
The maxSessionMemory is a cap for the amount of memory an Http2Session is permitted to consume. If exceeded, new `Http2Stream` sessions will be rejected with an `ENHANCE_YOUR_CALM` error and existing `Http2Stream` instances that are still receiving headers will be terminated with an `ENHANCE_YOUR_CALM` error. PR-URL: https://github.com/nodejs/node/pull/17967 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/internal/http2/util.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/internal/http2/util.js b/lib/internal/http2/util.js
index fffea10ab6..1411ab7cf7 100644
--- a/lib/internal/http2/util.js
+++ b/lib/internal/http2/util.js
@@ -175,7 +175,8 @@ const IDX_OPTIONS_PADDING_STRATEGY = 4;
const IDX_OPTIONS_MAX_HEADER_LIST_PAIRS = 5;
const IDX_OPTIONS_MAX_OUTSTANDING_PINGS = 6;
const IDX_OPTIONS_MAX_OUTSTANDING_SETTINGS = 7;
-const IDX_OPTIONS_FLAGS = 8;
+const IDX_OPTIONS_MAX_SESSION_MEMORY = 8;
+const IDX_OPTIONS_FLAGS = 9;
function updateOptionsBuffer(options) {
var flags = 0;
@@ -219,6 +220,11 @@ function updateOptionsBuffer(options) {
optionsBuffer[IDX_OPTIONS_MAX_OUTSTANDING_SETTINGS] =
Math.max(1, options.maxOutstandingSettings);
}
+ if (typeof options.maxSessionMemory === 'number') {
+ flags |= (1 << IDX_OPTIONS_MAX_SESSION_MEMORY);
+ optionsBuffer[IDX_OPTIONS_MAX_SESSION_MEMORY] =
+ Math.max(1, options.maxSessionMemory);
+ }
optionsBuffer[IDX_OPTIONS_FLAGS] = flags;
}