From baee7183af0392a32f8fb61b0c54a29d11de06d4 Mon Sep 17 00:00:00 2001 From: Michael Eischer <eischer@cs.fau.de> Date: Mon, 29 Aug 2022 18:42:33 +0200 Subject: [PATCH] network: Properly fix FAKE_WAN_DELAY timer initialization The REFITNetworkEndpointWorker is already prepared to delay the execution of some initialization code until it is called by its scheduler. Thus, just use this mechanism. --- src/refit/communication/REFITNetworkEndpointWorker.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/refit/communication/REFITNetworkEndpointWorker.java b/src/refit/communication/REFITNetworkEndpointWorker.java index e69475c..64b0afb 100644 --- a/src/refit/communication/REFITNetworkEndpointWorker.java +++ b/src/refit/communication/REFITNetworkEndpointWorker.java @@ -60,9 +60,7 @@ public class REFITNetworkEndpointWorker extends REFITSchedulerTask { if (address.nodeID != nodeID) { throw new IllegalArgumentException("Got connection for wrong node!"); } - if (REFITConfig.FAKE_WAN_DELAYS) { - timer = newTimer(this::timeout); - } + this.timer = null; this.address = address; try { connection.init(socketChannel); @@ -112,6 +110,9 @@ public class REFITNetworkEndpointWorker extends REFITSchedulerTask { // register() should only be called from the thread that owns the selector // otherwise registering a selectionKey may deadlock connection.register(this); + if (REFITConfig.FAKE_WAN_DELAYS) { + timer = newTimer(this::timeout); + } initCalled = false; } -- GitLab