diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index f628076b5..bf0a6a501 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -3608,6 +3608,12 @@ namespace libtorrent void peer_connection::connect(int ticket) { +#ifndef NDEBUG + // in case we disconnect here, we need to + // keep the connection alive until the + // exit invariant check is run + boost::intrusive_ptr me(self()); +#endif INVARIANT_CHECK; error_code ec;