| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9c1937c commit 977e9a3
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1106,11 +1106,22 @@ void ConnectionsList::Expired(const FunctionCallbackInfo<Value>& args) { | |||
| 1106 | 1106 | std::swap(headers_timeout, request_timeout); | |
| 1107 | 1107 | } | |
| 1108 | 1108 | ||
| 1109 | + // On IoT or embedded devices the uv_hrtime() may return the timestamp | ||
| 1110 | + // that is smaller than configured timeout for headers or request | ||
| 1111 | + // to prevent subtracting two unsigned integers | ||
| 1112 | + // that can yield incorrect results we should check | ||
| 1113 | + // if the 'now' is bigger than the timeout for headers or request | ||
| 1109 | 1114 | const uint64_t now = uv_hrtime(); | |
| 1110 | 1115 | const uint64_t headers_deadline = | |
| 1111 | - headers_timeout > 0 ? now - headers_timeout : 0; | ||
| 1116 | + (headers_timeout > 0 && now > headers_timeout) ? now - headers_timeout | ||
| 1117 | + : 0; | ||
| 1112 | 1118 | const uint64_t request_deadline = | |
| 1113 | - request_timeout > 0 ? now - request_timeout : 0; | ||
| 1119 | + (request_timeout > 0 && now > request_timeout) ? now - request_timeout | ||
| 1120 | + : 0; | ||
| 1121 | + | ||
| 1122 | + if (headers_deadline == 0 && request_deadline == 0) { | ||
| 1123 | + return args.GetReturnValue().Set(Array::New(isolate, 0)); | ||
| 1124 | + } | ||
| 1114 | 1125 | ||
| 1115 | 1126 | auto iter = list->active_connections_.begin(); | |
| 1116 | 1127 | auto end = list->active_connections_.end(); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments