From 7f84c28d9127b1303ad8e1fcd4eadbce8e1523c7 Mon Sep 17 00:00:00 2001 From: Arnaud Date: Mon, 1 Jun 2026 15:43:28 +0400 Subject: [PATCH] Check if the mapping is being destroyed in hasMapping --- libplum/plum.nim | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libplum/plum.nim b/libplum/plum.nim index 8253e8a..5defa9c 100644 --- a/libplum/plum.nim +++ b/libplum/plum.nim @@ -280,9 +280,12 @@ proc destroyMapping*(id: cint) {.raises: [].} = discard plum_destroy_mapping(id) proc hasMapping*(id: cint): bool {.raises: [].} = - ## Returns true if the mapping exists and has not been destroyed yet. - withSafeLock: - result = id in activeMappings + ## Returns true if the mapping exists and is not being destroyed. + var st: plum_state_t + if plum_query_mapping(id, addr st, nil) == PLUM_ERR_SUCCESS: + PlumState(st.int) notin {Destroying, Destroyed} + else: + false proc getLocalAddress*(): Result[string, string] {.raises: [].} = var buf = newString(PLUM_MAX_ADDRESS_LEN)