throttling fix 64/20764/1
authorMartin Bobak <mbobak@cisco.com>
Wed, 20 May 2015 05:45:16 +0000 (07:45 +0200)
committerMartin Bobak <mbobak@cisco.com>
Wed, 20 May 2015 06:34:08 +0000 (08:34 +0200)
 - fixed stuck condition

Change-Id: I6824fe66e1125f8f842a4e8ebd61ce31ac6c41e9
Signed-off-by: Martin Bobak <mbobak@cisco.com>
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImpl.java

index 15e96763cc21874ce3218af96c58f10c69d4e71e..ac003da9416c7c722ce255d0e09a9fbfed4a7aa6 100644 (file)
@@ -104,8 +104,8 @@ public class DeviceContextImpl implements DeviceContext {
     private final OutboundQueue outboundQueueProvider;
     private final MultiMsgCollector multiMsgCollector = new MultiMsgCollectorImpl();
 
-    private int outstandingNotificationsAmount = 0;
-    private boolean filteringPacketIn = false;
+    private volatile int outstandingNotificationsAmount = 0;
+    private volatile boolean filteringPacketIn = false;
     private Object throttlingLock = new Object();
     private int filteringHighWaterMark = 0;
 
@@ -287,12 +287,13 @@ public class DeviceContextImpl implements DeviceContext {
         }
 
         ListenableFuture<? extends Object> offerNotification = notificationPublishService.offerNotification(packetReceived);
-        outstandingNotificationsAmount += 1;
+        synchronized (throttlingLock) {
+            outstandingNotificationsAmount += 1;
+        }
         if (NotificationPublishService.REJECTED.equals(offerNotification)) {
             LOG.debug("notification offer rejected");
-            messageSpy.spyMessage(packetReceived.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.FROM_SWITCH_NOTIFICATION_REJECTED);
             synchronized (throttlingLock) {
-                if (outstandingNotificationsAmount > 0) {
+                if (outstandingNotificationsAmount > 1 && !filteringPacketIn) {
                     connectionAdapter.setPacketInFiltering(true);
                     filteringPacketIn = true;
                     filteringHighWaterMark = outstandingNotificationsAmount;