Fix southbound start/stop sequence 23/20223/1
authorLorand Jakab <lojakab@cisco.com>
Tue, 12 May 2015 17:01:11 +0000 (20:01 +0300)
committerLori Jakab <lojakab@cisco.com>
Wed, 13 May 2015 09:19:35 +0000 (09:19 +0000)
Change-Id: I865b818fa188f174fef9eff6d00b4ea62b4aa4ed
Signed-off-by: Lorand Jakab <lojakab@cisco.com>
(cherry picked from commit b2dfb13a01f7a494c3844b8399fd07848d4051db)

mappingservice/southbound/pom.xml
mappingservice/southbound/src/main/java/org/opendaylight/lispflowmapping/southbound/LispSouthboundPlugin.java

index 7a5f4e286fb00bf5e7813c944330a1adbec16133..01280e36f135621dd8d313c54ff445fedee0a7ef 100644 (file)
@@ -48,6 +48,7 @@
               org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.control.plane.rev150314.maprequestmessage,
               org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.control.plane.rev150314.mapreplynotification,
               com.google.common.net,
+              com.google.common.util.concurrent,
               org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924,
               org.opendaylight.controller.sal.core,
               org.apache.felix.dm,
index 9885afcb3971263e738958127ec7c3ab5dd66e69..9ca375f63ffe328688939c1c92b76c915fe3f379 100644 (file)
@@ -58,7 +58,6 @@ public class LispSouthboundPlugin extends AbstractBindingAwareProvider implement
     private final String MAP_REPlY = "MapReply";
     private final String MAP_REQUEST = "MapRequest";
     private volatile String bindingAddress = null;
-    private volatile boolean alreadyInit = false;
     private volatile int xtrPort = LispMessage.XTR_PORT_NUM;
     private volatile boolean listenOnXtrPort = false;
 
@@ -82,6 +81,7 @@ public class LispSouthboundPlugin extends AbstractBindingAwareProvider implement
         lispXtrSouthboundService = null;
         lispThread = null;
         xtrThread = null;
+        bindingAddress = null;
         LOG.info("LISP (RFC6830) Mapping Service is down!");
         try {
             Thread.sleep(1100);
@@ -171,6 +171,14 @@ public class LispSouthboundPlugin extends AbstractBindingAwareProvider implement
     }
 
     private void startIOThread() {
+        if (socket != null) {
+            while (!socket.isClosed()) {
+                try {
+                    Thread.sleep(500);
+                } catch (InterruptedException e) {
+                }
+            }
+        }
         try {
             socket = new DatagramSocket(new InetSocketAddress(bindingAddress, LispMessage.PORT_NUM));
             lispThread = new LispIoThread(socket, lispSouthboundService);
@@ -197,20 +205,16 @@ public class LispSouthboundPlugin extends AbstractBindingAwareProvider implement
     }
 
     public void onSessionInitiated(ProviderContext session) {
-        LOG.info("LISP (RFC6830) Mapping Service is up!");
         synchronized (startLock) {
-            if (!alreadyInit) {
-                alreadyInit = true;
-                lispSouthboundService = new LispSouthboundService();
-                lispXtrSouthboundService = new LispXtrSouthboundService();
-                registerWithOSGIConsole();
-                registerRPCs(session);
-                LOG.trace("Provider Session initialized");
-                if (bindingAddress == null) {
-                    setLispAddress("0.0.0.0");
-                }
+            lispSouthboundService = new LispSouthboundService();
+            lispXtrSouthboundService = new LispXtrSouthboundService();
+            registerWithOSGIConsole();
+            registerRPCs(session);
+            LOG.trace("Provider Session initialized");
+            if (bindingAddress == null) {
+                setLispAddress("0.0.0.0");
             }
-
+            LOG.info("LISP (RFC6830) Mapping Service is up!");
         }
     }