From 2d7c53932d684b29cbfd103d8ee3dcdf07400a0b Mon Sep 17 00:00:00 2001 From: Sho SHIMIZU Date: Tue, 30 Aug 2016 14:14:39 -0700 Subject: [PATCH] Make FlowOperationsProcessor thread-safe with synchronized modifier Different threads could call run(), satisfy() and fail() method. Each of the methods reads/writes multiple fields during the method call. These method calls need to be synchronized to gurantee to see the latest value. Change-Id: Ic252b56e0902170d7e0fdb83f96f0fb2e55ec56b --- .../java/org/onosproject/net/flow/impl/FlowRuleManager.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/net/src/main/java/org/onosproject/net/flow/impl/FlowRuleManager.java b/core/net/src/main/java/org/onosproject/net/flow/impl/FlowRuleManager.java index 8d74464706..b4c32010b9 100644 --- a/core/net/src/main/java/org/onosproject/net/flow/impl/FlowRuleManager.java +++ b/core/net/src/main/java/org/onosproject/net/flow/impl/FlowRuleManager.java @@ -609,7 +609,7 @@ public class FlowRuleManager } @Override - public void run() { + public synchronized void run() { if (stages.size() > 0) { process(stages.remove(0)); } else if (!hasFailed.get() && context != null) { @@ -654,7 +654,7 @@ public class FlowRuleManager } } - void satisfy(DeviceId devId) { + synchronized void satisfy(DeviceId devId) { pendingDevices.remove(devId); if (pendingDevices.isEmpty()) { operationsService.execute(this); @@ -663,7 +663,7 @@ public class FlowRuleManager - void fail(DeviceId devId, Set failures) { + synchronized void fail(DeviceId devId, Set failures) { hasFailed.set(true); pendingDevices.remove(devId); if (pendingDevices.isEmpty()) {