Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
1724a4e
src: add optional keep-alive object to SetImmediate
addaleax Nov 21, 2017
df31133
http2: don't call into JS from GC
addaleax Nov 21, 2017
8c28e30
http2: only schedule write when necessary
addaleax Nov 21, 2017
504ee24
http2: be sure to destroy the Http2Stream
jasnell Nov 27, 2017
ac89b78
http2: cleanup Http2Stream/Http2Session destroy
jasnell Dec 12, 2017
7ab5c62
http2: remove redundant write indirection
addaleax Dec 17, 2017
66be8e5
http2: refactor outgoing write mechanism
addaleax Dec 17, 2017
293c2f9
http2: convert Http2Settings to an AsyncWrap
jasnell Dec 18, 2017
08478c1
http2: fix compiling with `--debug-http2`
addaleax Dec 25, 2017
b61c3fc
http2: keep session objects alive during Http2Scope
addaleax Dec 25, 2017
afa4a7c
http2: implement ref() and unref() on client sessions
kjin Dec 11, 2017
8d8dfea
http2: remove duplicate words in comments
tniessen Jan 1, 2018
d968c02
http2: perf_hooks integration
jasnell Dec 20, 2017
bf7eed3
http2: strictly limit number on concurrent streams
jasnell Nov 21, 2017
8df5d02
http2: add altsvc support
jasnell Dec 29, 2017
ae4e308
tls: set servername on client side too
jasnell Jan 1, 2018
7d6aa20
http2: add initial support for originSet
jasnell Jan 1, 2018
760f678
http2: add aligned padding strategy
jasnell Jan 1, 2018
06ed513
http2: properly handle already closed stream error
jasnell Jan 2, 2018
e929bd0
doc: add docs for common/http2.js utility
jasnell Jan 2, 2018
c1c4a6c
src: silence http2 -Wunused-result warnings
cjihrig Jan 2, 2018
adbc38a
http2: implement maxSessionMemory
jasnell Jan 3, 2018
51dc318
http2: verify that a dependency cycle may exist
jasnell Jan 3, 2018
d1e75eb
doc: grammar fixes in http2.md
Trott Jan 4, 2018
cd6fcf3
http2: verify flood error and unsolicited frames
jasnell Jan 3, 2018
526cf84
doc: correct spelling
sreepurnajasti Dec 29, 2017
d7dd941
perf_hooks: fix scheduling regression
apapirovski Jan 9, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
http2: convert Http2Settings to an AsyncWrap
PR-URL: #17763
Refs: #17746
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
  • Loading branch information
jasnell authored and MylesBorins committed Jan 9, 2018
commit 293c2f90de4332a6e28143a8a78196d59a2ea76f
57 changes: 31 additions & 26 deletions lib/internal/http2/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,23 +322,14 @@ function onStreamRead(nread, buf, handle) {

// Called when the remote peer settings have been updated.
// Resets the cached settings.
function onSettings(ack) {
function onSettings() {
const session = this[kOwner];
if (session.destroyed)
return;
session[kUpdateTimer]();
let event = 'remoteSettings';
if (ack) {
debug(`Http2Session ${sessionName(session[kType])}: settings acknowledged`);
if (session[kState].pendingAck > 0)
session[kState].pendingAck--;
session[kLocalSettings] = undefined;
event = 'localSettings';
} else {
debug(`Http2Session ${sessionName(session[kType])}: new settings received`);
session[kRemoteSettings] = undefined;
}
process.nextTick(emit, session, event, session[event]);
debug(`Http2Session ${sessionName(session[kType])}: new settings received`);
session[kRemoteSettings] = undefined;
process.nextTick(emit, session, 'remoteSettings', session.remoteSettings);
}

// If the stream exists, an attempt will be made to emit an event
Expand Down Expand Up @@ -538,15 +529,32 @@ function onSessionInternalError(code) {
this[kOwner].destroy(new NghttpError(code));
}

function settingsCallback(cb, ack, duration) {
this[kState].pendingAck--;
this[kLocalSettings] = undefined;
if (ack) {
debug(`Http2Session ${sessionName(this[kType])}: settings received`);
const settings = this.localSettings;
if (typeof cb === 'function')
cb(null, settings, duration);
this.emit('localSettings', settings);
} else {
debug(`Http2Session ${sessionName(this[kType])}: settings canceled`);
if (typeof cb === 'function')
cb(new errors.Error('ERR_HTTP2_SETTINGS_CANCEL'));
}
}

// Submits a SETTINGS frame to be sent to the remote peer.
function submitSettings(settings) {
function submitSettings(settings, callback) {
if (this.destroyed)
return;
debug(`Http2Session ${sessionName(this[kType])}: submitting settings`);
this[kUpdateTimer]();
this[kLocalSettings] = undefined;
updateSettingsBuffer(settings);
this[kHandle].settings();
if (!this[kHandle].settings(settingsCallback.bind(this, callback))) {
this.destroy(new errors.Error('ERR_HTTP2_MAX_PENDING_SETTINGS_ACK'));
}
}

// Submits a PRIORITY frame to be sent to the remote peer
Expand Down Expand Up @@ -781,7 +789,6 @@ class Http2Session extends EventEmitter {
streams: new Map(),
pendingStreams: new Set(),
pendingAck: 0,
maxPendingAck: Math.max(1, (options.maxPendingAck | 0) || 10),
writeQueueSize: 0
};

Expand Down Expand Up @@ -948,21 +955,19 @@ class Http2Session extends EventEmitter {
}

// Submits a SETTINGS frame to be sent to the remote peer.
settings(settings) {
settings(settings, callback) {
if (this.destroyed)
throw new errors.Error('ERR_HTTP2_INVALID_SESSION');

assertIsObject(settings, 'settings');
settings = validateSettings(settings);
const state = this[kState];
if (state.pendingAck === state.maxPendingAck) {
throw new errors.Error('ERR_HTTP2_MAX_PENDING_SETTINGS_ACK',
this[kState].pendingAck);
}

if (callback && typeof callback !== 'function')
throw new errors.TypeError('ERR_INVALID_CALLBACK');
debug(`Http2Session ${sessionName(this[kType])}: sending settings`);

state.pendingAck++;
const settingsFn = submitSettings.bind(this, settings);
this[kState].pendingAck++;

const settingsFn = submitSettings.bind(this, settings, callback);
if (this.connecting) {
this.once('connect', settingsFn);
return;
Expand Down
8 changes: 7 additions & 1 deletion lib/internal/http2/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ const IDX_OPTIONS_PEER_MAX_CONCURRENT_STREAMS = 3;
const IDX_OPTIONS_PADDING_STRATEGY = 4;
const IDX_OPTIONS_MAX_HEADER_LIST_PAIRS = 5;
const IDX_OPTIONS_MAX_OUTSTANDING_PINGS = 6;
const IDX_OPTIONS_FLAGS = 7;
const IDX_OPTIONS_MAX_OUTSTANDING_SETTINGS = 7;
const IDX_OPTIONS_FLAGS = 8;

function updateOptionsBuffer(options) {
var flags = 0;
Expand Down Expand Up @@ -213,6 +214,11 @@ function updateOptionsBuffer(options) {
optionsBuffer[IDX_OPTIONS_MAX_OUTSTANDING_PINGS] =
options.maxOutstandingPings;
}
if (typeof options.maxOutstandingSettings === 'number') {
flags |= (1 << IDX_OPTIONS_MAX_OUTSTANDING_SETTINGS);
optionsBuffer[IDX_OPTIONS_MAX_OUTSTANDING_SETTINGS] =
Math.max(1, options.maxOutstandingSettings);
}
optionsBuffer[IDX_OPTIONS_FLAGS] = flags;
}

Expand Down
1 change: 1 addition & 0 deletions src/async_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ namespace node {
V(HTTP2SESSION) \
V(HTTP2STREAM) \
V(HTTP2PING) \
V(HTTP2SETTINGS) \
V(HTTPPARSER) \
V(JSSTREAM) \
V(PIPECONNECTWRAP) \
Expand Down
1 change: 1 addition & 0 deletions src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ class ModuleWrap;
V(context, v8::Context) \
V(http2ping_constructor_template, v8::ObjectTemplate) \
V(http2stream_constructor_template, v8::ObjectTemplate) \
V(http2settings_constructor_template, v8::ObjectTemplate) \
V(inspector_console_api_object, v8::Object) \
V(module_load_list_array, v8::Array) \
V(pbkdf2_constructor_template, v8::ObjectTemplate) \
Expand Down
Loading