Skip to content

Commit 92ba624

Browse files
committed
tls: provide now value from C++
Instead of separately calling into C++ from JS to retrieve the Timer.now() value, pass it in as an argument. PR-URL: #18562 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent 1573e45 commit 92ba624

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

lib/_tls_wrap.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ const common = require('_tls_common');
3232
const { StreamWrap } = require('_stream_wrap');
3333
const { Buffer } = require('buffer');
3434
const debug = util.debuglog('tls');
35-
const { Timer } = process.binding('timer_wrap');
3635
const tls_wrap = process.binding('tls_wrap');
3736
const { TCP, constants: TCPConstants } = process.binding('tcp_wrap');
3837
const { Pipe, constants: PipeConstants } = process.binding('pipe_wrap');
@@ -49,14 +48,13 @@ const kSNICallback = Symbol('snicallback');
4948

5049
const noop = () => {};
5150

52-
function onhandshakestart() {
51+
function onhandshakestart(now) {
5352
debug('onhandshakestart');
5453

55-
const owner = this.owner;
56-
const now = Timer.now();
57-
5854
assert(now >= this.lastHandshakeTime);
5955

56+
const owner = this.owner;
57+
6058
if ((now - this.lastHandshakeTime) >= tls.CLIENT_RENEG_WINDOW * 1000) {
6159
this.handshakes = 0;
6260
}

src/tls_wrap.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ void TLSWrap::SSLInfoCallback(const SSL* ssl_, int where, int ret) {
230230
if (where & SSL_CB_HANDSHAKE_START) {
231231
Local<Value> callback = object->Get(env->onhandshakestart_string());
232232
if (callback->IsFunction()) {
233-
c->MakeCallback(callback.As<Function>(), 0, nullptr);
233+
Local<Value> argv[] = { env->GetNow() };
234+
c->MakeCallback(callback.As<Function>(), arraysize(argv), argv);
234235
}
235236
}
236237

0 commit comments

Comments
 (0)