Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http: fix for handling on boot timers headers and request #48291

Merged
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
15 changes: 13 additions & 2 deletions src/node_http_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1106,11 +1106,22 @@ void ConnectionsList::Expired(const FunctionCallbackInfo<Value>& args) {
std::swap(headers_timeout, request_timeout);
}

// On IoT or embedded devices the uv_hrtime() may return the timestamp
// that is smaller than configured timeout for headers or request
// to prevent subtracting two unsigned integers
// that can yield incorrect results we should check
// if the 'now' is bigger than the timeout for headers or request
const uint64_t now = uv_hrtime();
const uint64_t headers_deadline =
headers_timeout > 0 ? now - headers_timeout : 0;
(headers_timeout > 0 && now > headers_timeout) ? now - headers_timeout
: 0;
const uint64_t request_deadline =
request_timeout > 0 ? now - request_timeout : 0;
(request_timeout > 0 && now > request_timeout) ? now - request_timeout
: 0;

if (headers_deadline == 0 && request_deadline == 0) {
return args.GetReturnValue().Set(Array::New(isolate, 0));
}

auto iter = list->active_connections_.begin();
auto end = list->active_connections_.end();
Expand Down