Skip to content

Commit

Permalink
Always unregister disconnect_detector in ListenRequest
Browse files Browse the repository at this point in the history
For monitoring the connection state, while waiting for the
StorageEngine, Listen request is using the disconnect_detector. However,
if waiting for the storage engine throws, the disconnect_detector (the
scope class), stays registered in the epoll, causing the trigger and
possible crash, as the stack may not be here anymore.

This patch always unregisters disconnect_detector from epoll, nevermind
the return/exception of the waitEvents.
  • Loading branch information
nemanja-boric-sociomantic authored and Gavin Norman committed Oct 9, 2017
1 parent 64f4c14 commit 055eceb
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/dhtproto/node/request/Listen.d
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,15 @@ public abstract scope class Listen : SingleChannel
// the cleanup also assumes the "write" event was active).
this.writer.fiber.unregister();
this.reader.fiber.epoll.register(disconnect_detector);
this.waitEvents(finish, flush);
this.reader.fiber.epoll.unregister(disconnect_detector);

try
{
this.waitEvents(finish, flush);
}
finally
{
this.reader.fiber.epoll.unregister(disconnect_detector);
}

if (disconnect_detector.disconnected)
return;
Expand Down

0 comments on commit 055eceb

Please sign in to comment.