mirror of
https://github.com/logos-storage/nim-libplum.git
synced 2026-06-07 01:29:27 +00:00
Clean up destroyMapping doc and redundant guard
This commit is contained in:
parent
e5adc98f2e
commit
055e8410af
8
api.md
8
api.md
@ -108,10 +108,10 @@ Returns an error if no NAT device is found, the mapping fails, or the timeout ex
|
||||
proc destroyMapping*(id: cint)
|
||||
```
|
||||
|
||||
Removes a mapping. Must be called exactly once after a successful `createMapping`,
|
||||
otherwise the mapping's internal handle is leaked for the lifetime of the process.
|
||||
Calling it again, or with an unknown `id`, is a safe no-op. `cleanup` also releases
|
||||
any mappings still active.
|
||||
Removes a mapping. Call it after a successful `createMapping`, otherwise the
|
||||
mapping's internal handle is leaked for the lifetime of the process. Calling it
|
||||
again, or with an unknown `id`, is a safe no-op. `cleanup` also releases any
|
||||
mappings still active.
|
||||
|
||||
### hasMapping
|
||||
|
||||
|
||||
@ -274,11 +274,10 @@ proc createMapping*(
|
||||
return err("plum: mapping " & $id & " failed")
|
||||
|
||||
proc destroyMapping*(id: cint) =
|
||||
## Must be called exactly once after a successful createMapping.
|
||||
## Safe to call again or on an unknown id
|
||||
withSafeLock:
|
||||
if id notin activeMappings:
|
||||
return
|
||||
## Releases a mapping created by createMapping. Safe to call again or
|
||||
## with an unknown id.
|
||||
# libplum locks internally and ignores unknown ids: no wrapper-side
|
||||
# bookkeeping needed.
|
||||
discard plum_destroy_mapping(id)
|
||||
|
||||
proc hasMapping*(id: cint): bool =
|
||||
|
||||
@ -14,7 +14,6 @@ import unittest2
|
||||
import std/atomics
|
||||
import chronos
|
||||
import libplum/plum
|
||||
import libplum/libplum
|
||||
|
||||
const miniupnp_protocol {.strdefine.} = ""
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user