From 10be548ee974a0e53e6854a1f1352b4078d0eb34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Mon, 14 Dec 2020 14:10:59 +0100 Subject: [PATCH] Fix potential race condition in rpc adapter. --- src/main/java/li/cil/oc2/common/bus/RPCAdapter.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/li/cil/oc2/common/bus/RPCAdapter.java b/src/main/java/li/cil/oc2/common/bus/RPCAdapter.java index cdbb2d24..43d24867 100644 --- a/src/main/java/li/cil/oc2/common/bus/RPCAdapter.java +++ b/src/main/java/li/cil/oc2/common/bus/RPCAdapter.java @@ -147,8 +147,12 @@ public final class RPCAdapter implements Steppable { if (synchronizedInvocation != null) { final MethodInvocation methodInvocation = synchronizedInvocation; - synchronizedInvocation = null; processMethodInvocation(methodInvocation, true); + + // This is also used to prevent thread from processing messages, so only + // reset this when we're done. Otherwise we may get a race-condition when + // writing back data. + synchronizedInvocation = null; } }