From e7fae773b67ee53c26cfbe46a34ef4b62ec61e66 Mon Sep 17 00:00:00 2001
From: Srinivasan Ramasubramanian <srini@bigswitch.com>
Date: Mon, 16 Jan 2012 15:26:08 -0800
Subject: [PATCH] Fixes to DeviceUpdateWorker on map updates.

---
 .../internal/DeviceManagerImpl.java           | 20 +++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java b/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java
index 92bd7c338..c0bcfcfc1 100755
--- a/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java
+++ b/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java
@@ -1864,12 +1864,8 @@ public class DeviceManagerImpl implements IDeviceManager, IOFMessageListener,
                             for (Device d: devMgrMaps.getDevicesOnASwitch(sw)) {
                                 Device dCopy = new Device(d);
                                 cleanupAttachmentPoints(dCopy);
-                                /*
-                                evHistAttachmtPt(dCopy, 0L, (short)(-1),
-                                        EvAction.UPDATED, "DeviceUpdateWorker");
-                                */
                                 for (DeviceAttachmentPoint dap : 
-                                            dCopy.getOldAttachmentPoints()) {
+                                    dCopy.getOldAttachmentPoints()) {
                                     // Don't remove conflict attachment points 
                                     // with recent activities
                                     if (dap.isInConflict())
@@ -1879,21 +1875,25 @@ public class DeviceManagerImpl implements IDeviceManager, IOFMessageListener,
                                     // leave stale attachment points on storage.
                                     removeAttachmentPointFromStorage(dCopy, dap);
                                     dCopy.removeOldAttachmentPoint(dap);
-                                    // Update the maps with the new dev. copy
-                                    devMgrMaps.updateMaps(dCopy);
                                 }
+                                // Update the maps with the new device copy
+                                devMgrMaps.updateMaps(dCopy);
                             }
-                            maxIter = 0;
+                            break;
                         }  catch (ConcurrentModificationException e) {
                             maxIter--;
                         } catch (NullPointerException e) { }
                     }
+                    if (maxIter == 0) {
+                        log.warn("Device attachment point clean up " +
+                                "attempted three times and failed.");
+                    }
                 }
                 log.debug("DeviceUpdateWorker: finished cleaning up device " +
-                            "attachment points");
+                          "attachment points");
             } catch (StorageException e) {
                 log.error("DeviceUpdateWorker had a storage exception, " +
-                            "Floodlight exiting");
+                        "Floodlight exiting");
                 System.exit(1);
             }
         }
-- 
GitLab