Reference copies of atomic lists when calling them (in case the list is cleared in a reentrant call
This commit is contained in:
parent
cf4b61f4de
commit
7e748bd7dc
@ -367,7 +367,8 @@ internal class ListenerManager<CONNECTION: Connection>(private val logger: KLogg
|
|||||||
* Invoked when a connection is first initialized, but BEFORE it's connected to the remote address.
|
* Invoked when a connection is first initialized, but BEFORE it's connected to the remote address.
|
||||||
*/
|
*/
|
||||||
suspend fun notifyInit(connection: CONNECTION) {
|
suspend fun notifyInit(connection: CONNECTION) {
|
||||||
onInitList.value.forEach {
|
val list = onInitList.value
|
||||||
|
list.forEach {
|
||||||
try {
|
try {
|
||||||
it(connection)
|
it(connection)
|
||||||
} catch (t: Throwable) {
|
} catch (t: Throwable) {
|
||||||
@ -382,7 +383,8 @@ internal class ListenerManager<CONNECTION: Connection>(private val logger: KLogg
|
|||||||
* Invoked when a connection is connected to a remote address.
|
* Invoked when a connection is connected to a remote address.
|
||||||
*/
|
*/
|
||||||
suspend fun notifyConnect(connection: CONNECTION) {
|
suspend fun notifyConnect(connection: CONNECTION) {
|
||||||
onConnectList.value.forEach {
|
val list = onConnectList.value
|
||||||
|
list.forEach {
|
||||||
try {
|
try {
|
||||||
it(connection)
|
it(connection)
|
||||||
} catch (t: Throwable) {
|
} catch (t: Throwable) {
|
||||||
@ -397,7 +399,8 @@ internal class ListenerManager<CONNECTION: Connection>(private val logger: KLogg
|
|||||||
* Invoked when a connection is disconnected to a remote address.
|
* Invoked when a connection is disconnected to a remote address.
|
||||||
*/
|
*/
|
||||||
suspend fun notifyDisconnect(connection: CONNECTION) {
|
suspend fun notifyDisconnect(connection: CONNECTION) {
|
||||||
onDisconnectList.value.forEach {
|
val list = onDisconnectList.value
|
||||||
|
list.forEach {
|
||||||
try {
|
try {
|
||||||
it(connection)
|
it(connection)
|
||||||
} catch (t: Throwable) {
|
} catch (t: Throwable) {
|
||||||
@ -416,7 +419,8 @@ internal class ListenerManager<CONNECTION: Connection>(private val logger: KLogg
|
|||||||
fun notifyError(connection: CONNECTION, exception: Throwable) {
|
fun notifyError(connection: CONNECTION, exception: Throwable) {
|
||||||
logger.error("Error with connection $connection", exception)
|
logger.error("Error with connection $connection", exception)
|
||||||
|
|
||||||
onErrorList.value.forEach {
|
val list = onErrorList.value
|
||||||
|
list.forEach {
|
||||||
try {
|
try {
|
||||||
it(connection, exception)
|
it(connection, exception)
|
||||||
} catch (t: Throwable) {
|
} catch (t: Throwable) {
|
||||||
@ -435,7 +439,8 @@ internal class ListenerManager<CONNECTION: Connection>(private val logger: KLogg
|
|||||||
fun notifyError(exception: Throwable) {
|
fun notifyError(exception: Throwable) {
|
||||||
logger.error("Global error", exception)
|
logger.error("Global error", exception)
|
||||||
|
|
||||||
onErrorGlobalList.value.forEach {
|
val list = onErrorGlobalList.value
|
||||||
|
list.forEach {
|
||||||
try {
|
try {
|
||||||
it(exception)
|
it(exception)
|
||||||
} catch (t: Throwable) {
|
} catch (t: Throwable) {
|
||||||
|
Loading…
Reference in New Issue
Block a user