From f6abddb99f173d72fadce73ebc0b4f8b40b9dc8b Mon Sep 17 00:00:00 2001 From: Lorand Jakab Date: Tue, 12 May 2015 20:01:11 +0300 Subject: [PATCH] Fix southbound start/stop sequence Change-Id: I865b818fa188f174fef9eff6d00b4ea62b4aa4ed Signed-off-by: Lorand Jakab (cherry picked from commit b2dfb13a01f7a494c3844b8399fd07848d4051db) --- mappingservice/southbound/pom.xml | 1 + .../southbound/LispSouthboundPlugin.java | 30 +++++++++++-------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/mappingservice/southbound/pom.xml b/mappingservice/southbound/pom.xml index 7a5f4e286..01280e36f 100644 --- a/mappingservice/southbound/pom.xml +++ b/mappingservice/southbound/pom.xml @@ -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, diff --git a/mappingservice/southbound/src/main/java/org/opendaylight/lispflowmapping/southbound/LispSouthboundPlugin.java b/mappingservice/southbound/src/main/java/org/opendaylight/lispflowmapping/southbound/LispSouthboundPlugin.java index 9885afcb3..9ca375f63 100644 --- a/mappingservice/southbound/src/main/java/org/opendaylight/lispflowmapping/southbound/LispSouthboundPlugin.java +++ b/mappingservice/southbound/src/main/java/org/opendaylight/lispflowmapping/southbound/LispSouthboundPlugin.java @@ -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!"); } } -- 2.36.6