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
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 8d74464..b4c3201 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 @@
}
@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 @@
}
}
- void satisfy(DeviceId devId) {
+ synchronized void satisfy(DeviceId devId) {
pendingDevices.remove(devId);
if (pendingDevices.isEmpty()) {
operationsService.execute(this);
@@ -663,7 +663,7 @@
- void fail(DeviceId devId, Set<? extends FlowRule> failures) {
+ synchronized void fail(DeviceId devId, Set<? extends FlowRule> failures) {
hasFailed.set(true);
pendingDevices.remove(devId);
if (pendingDevices.isEmpty()) {