Ensure Subrouting is closed if register fails
This commit is contained in:
@@ -62,8 +62,12 @@ class Subrouting(private val parent: Routing, priority: Int, val upstream: Strin
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
Timber.d("Subrouting initialized from %s to %s", parent.downstream, upstream)
|
Timber.d("Subrouting initialized from %s to %s", parent.downstream, upstream)
|
||||||
Timber.d(Thread.currentThread().stackTrace.joinToString("\n"))
|
try {
|
||||||
IpNeighbourMonitor.registerCallback(this)
|
IpNeighbourMonitor.registerCallback(this)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
close()
|
||||||
|
throw e
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,7 +76,6 @@ class Subrouting(private val parent: Routing, priority: Int, val upstream: Strin
|
|||||||
override fun close() {
|
override fun close() {
|
||||||
IpNeighbourMonitor.unregisterCallback(this)
|
IpNeighbourMonitor.unregisterCallback(this)
|
||||||
Timber.d("Subrouting closed from %s to %s", parent.downstream, upstream)
|
Timber.d("Subrouting closed from %s to %s", parent.downstream, upstream)
|
||||||
Timber.d(Thread.currentThread().stackTrace.joinToString("\n"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onIpNeighbourAvailable(neighbours: List<IpNeighbour>) = synchronized(parent) {
|
override fun onIpNeighbourAvailable(neighbours: List<IpNeighbour>) = synchronized(parent) {
|
||||||
|
|||||||
Reference in New Issue
Block a user