Skip to content
This repository was archived by the owner on May 3, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions in_response.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ function TChannelInResponse(id, options) {
self.arg3 = emptyBuffer;

self.start = self.timers.now();
self.timeout = 0;

self.finishEvent.on(self.onFinish);
}
Expand Down
13 changes: 12 additions & 1 deletion out_request.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ function TChannelOutRequest(id, options) {
this.checksum = options.checksum || null;
this.forwardTrace = options.forwardTrace || false;

// All self requests have id 0
this.operations = null;
this.timeHeapHandle = null;
this.id = id;
Expand All @@ -80,10 +79,22 @@ function TChannelOutRequest(id, options) {
this.drained = false;
this.drainReason = '';

this.start = this.channel.timers.now();
this.timeout = options.timeout || this.channel.maximumRelayTTL;

// Truncate timeout if parent deadline is sooner.
if (this.parent) {
var parentDeadline = this.parent.start + this.parent.timeout;
var childDeadline = this.start + this.timeout;
var deadline = Math.min(parentDeadline, childDeadline);
this.timeout = Math.max(0, deadline - this.start);
}

if (options.channel.tracer && !this.forwardTrace) {
// new span with new ids
this.setupTracing(options);
}

}

inherits(TChannelOutRequest, EventEmitter);
Expand Down
9 changes: 9 additions & 0 deletions v2/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,15 @@ TChannelV2Handler.prototype.handleCallResponse = function handleCallResponse(res

var req = this.connection.ops.getOutReq(res.id);

if (!req) {
// Drop call response frames for requests that expire.
return;
}

// Copy the timeout from request to response for propagation when the in
// response is used as the parent context for an out request.
res.timeout = req.timeout;

var channel = this.connection.channel;

channel.emitFastStat(
Expand Down