Sho SHIMIZU

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
...@@ -587,7 +587,7 @@ public class FlowRuleManager ...@@ -587,7 +587,7 @@ public class FlowRuleManager
587 } 587 }
588 588
589 @Override 589 @Override
590 - public void run() { 590 + public synchronized void run() {
591 if (stages.size() > 0) { 591 if (stages.size() > 0) {
592 process(stages.remove(0)); 592 process(stages.remove(0));
593 } else if (!hasFailed.get() && context != null) { 593 } else if (!hasFailed.get() && context != null) {
...@@ -632,7 +632,7 @@ public class FlowRuleManager ...@@ -632,7 +632,7 @@ public class FlowRuleManager
632 } 632 }
633 } 633 }
634 634
635 - void satisfy(DeviceId devId) { 635 + synchronized void satisfy(DeviceId devId) {
636 pendingDevices.remove(devId); 636 pendingDevices.remove(devId);
637 if (pendingDevices.isEmpty()) { 637 if (pendingDevices.isEmpty()) {
638 operationsService.execute(this); 638 operationsService.execute(this);
...@@ -641,7 +641,7 @@ public class FlowRuleManager ...@@ -641,7 +641,7 @@ public class FlowRuleManager
641 641
642 642
643 643
644 - void fail(DeviceId devId, Set<? extends FlowRule> failures) { 644 + synchronized void fail(DeviceId devId, Set<? extends FlowRule> failures) {
645 hasFailed.set(true); 645 hasFailed.set(true);
646 pendingDevices.remove(devId); 646 pendingDevices.remove(devId);
647 if (pendingDevices.isEmpty()) { 647 if (pendingDevices.isEmpty()) {
......