Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
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: simplify and improve priority
  • Loading branch information
jasnell committed Nov 22, 2017
commit 215a347c6c9996fff71f84bbcc06d7abe9f18be0
31 changes: 10 additions & 21 deletions lib/internal/http2/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,11 @@ function submitPriority(options) {
_unrefActive(this);
_unrefActive(this[kSession]);

// If the parent is the id, do nothing because a
// stream cannot be made to depend on itself.
if (options.parent === this[kID])
return;

this[kHandle].priority(options.parent | 0,
options.weight | 0,
!!options.exclusive,
Expand Down Expand Up @@ -1405,33 +1410,17 @@ class Http2Stream extends Duplex {
priority(options) {
if (this.destroyed)
throw new errors.Error('ERR_HTTP2_INVALID_STREAM');
const session = this[kSession];
if (this[kID] === undefined) {
this.once('ready', this.priority.bind(this, options));
return;
}
debug(`Http2Stream ${this[kID]} [Http2Session ` +
`${sessionName(session[kType])}]: sending priority`);
_unrefActive(this);

assertIsObject(options, 'options');
options = Object.assign(Object.create(null), options);
options = Object.assign({}, options);
validatePriorityOptions(options);

const id = this[kID];

// A stream cannot be made to depend on itself
if (options.parent === id) {
throw new errors.TypeError('ERR_INVALID_OPT_VALUE',
'parent',
options.parent);
}

if (id === undefined) {
this.once('ready', submitPriority.bind(this, options));
const fn = submitPriority.bind(this, options);
if (this[kID] === undefined) {
this.once('ready', fn);
return;
}
submitPriority.call(this, options);
fn();
}

// Called by this.destroy().
Expand Down
57 changes: 0 additions & 57 deletions test/parallel/test-http2-priority-parent-self.js

This file was deleted.