Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions libp2p/protocols/service_discovery.nim
Original file line number Diff line number Diff line change
Expand Up @@ -173,28 +173,28 @@ method stop*(disco: ServiceDiscovery) {.async: (raises: []).} =

# stops the advertiser maintenance loop before draining advertiser tasks,
# so shutdown cannot spawn new registration work while cleanup is running
if not disco.advertiserMaintenanceLoop.isNil():
if not disco.advertiserMaintenanceLoop.isNil:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit?

Suggested change
if not disco.advertiserMaintenanceLoop.isNil:
if not disco.advertiserMaintenanceLoop.isNil():

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adjective-like getters should not use ()

await disco.advertiserMaintenanceLoop.cancelAndWait()
disco.advertiserMaintenanceLoop = nil

await disco.advertiser.clear()

disco.serviceBootstrapFuts.cancelSoon()
disco.serviceBootstrapFuts = @[]
let serviceBootstrapFuts = move disco.serviceBootstrapFuts

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting trick

await noCancel serviceBootstrapFuts.cancelAndWait()

if not disco.selfSignedPeerRecordLoop.isNil():
disco.selfSignedPeerRecordLoop.cancelSoon()
if not disco.selfSignedPeerRecordLoop.isNil:
await disco.selfSignedPeerRecordLoop.cancelAndWait()
disco.selfSignedPeerRecordLoop = nil

if not disco.pruneExpiredAdsLoop.isNil():
disco.pruneExpiredAdsLoop.cancelSoon()
if not disco.pruneExpiredAdsLoop.isNil:
await disco.pruneExpiredAdsLoop.cancelAndWait()
disco.pruneExpiredAdsLoop = nil

if not disco.refreshServiceTablesLoop.isNil():
disco.refreshServiceTablesLoop.cancelSoon()
if not disco.refreshServiceTablesLoop.isNil:
await disco.refreshServiceTablesLoop.cancelAndWait()
disco.refreshServiceTablesLoop = nil

if not disco.localRegistrationLoop.isNil():
if not disco.localRegistrationLoop.isNil:
await disco.localRegistrationLoop.cancelAndWait()
disco.localRegistrationLoop = nil

Expand Down
Loading