diff --git a/src/refit/communication/REFITNetworkEndpointWorker.java b/src/refit/communication/REFITNetworkEndpointWorker.java index e69475c5d7270bbb994dd7b1d7ed3af23f7a8523..64b0afb8a7a4e36191a66218d432abdbbe69db3f 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; }