Skip to content

Commit

Permalink
Use cancelSoon instead of deprecated cancel
Browse files Browse the repository at this point in the history
  • Loading branch information
kdeme committed Jan 12, 2024
1 parent cbcd1fd commit caf827a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions eth/p2p/discoveryv5/protocol.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1041,11 +1041,11 @@ proc close*(d: Protocol) =

debug "Closing discovery node", node = d.localNode
if not d.revalidateLoop.isNil:
d.revalidateLoop.cancel()
d.revalidateLoop.cancelSoon()
if not d.refreshLoop.isNil:
d.refreshLoop.cancel()
d.refreshLoop.cancelSoon()
if not d.ipMajorityLoop.isNil:
d.ipMajorityLoop.cancel()
d.ipMajorityLoop.cancelSoon()

d.transp.close()

Expand Down
4 changes: 2 additions & 2 deletions eth/utp/utp_socket.nim
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ proc destroy*(s: UtpSocket) =
## Moves socket to destroy state and clean all resources.
## Remote is not notified in any way about socket end of life.
s.state = Destroy
s.eventLoop.cancel()
s.eventLoop.cancelSoon()
# This procedure initiate cleanup process which goes like:
# Cancel EventLoop -> Cancel timeoutsLoop -> Fire closeEvent
# This is necessary due to how evenLoop look like i.e it has only one await
Expand Down Expand Up @@ -1758,7 +1758,7 @@ proc eventLoop(socket: UtpSocket) {.async.} =
socket.pendingWrites.clear()
socket.pendingReads.clear()
# main eventLoop has been cancelled, try to cancel `checkTimeoutsLoop`
socket.checkTimeoutsLoop.cancel()
socket.checkTimeoutsLoop.cancelSoon()
trace "main socket event loop cancelled"
raise exc

Expand Down
4 changes: 2 additions & 2 deletions tests/utp/test_utp_socket.nim
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ procSuite "uTP socket tests":
initialPacket.header.wndSize == defaultConfig.optRcvBuffer

await socket.destroyWait()
fut.cancel()
fut.cancelSoon()

asyncTest "Outgoing socket should re-send SYN packet 2 times before declaring failure":
let q = newAsyncQueue[Packet]()
Expand Down Expand Up @@ -82,7 +82,7 @@ procSuite "uTP socket tests":
not socket.isConnected()

await socket.destroyWait()
fut1.cancel()
fut1.cancelSoon()

asyncTest "Processing in order ack should make socket connected":
let q = newAsyncQueue[Packet]()
Expand Down

0 comments on commit caf827a

Please sign in to comment.