Skip to content

Commit

Permalink
Reorder destructor code in a more logical way.
Browse files Browse the repository at this point in the history
  • Loading branch information
s-ludwig committed Mar 25, 2024
1 parent ddd5225 commit 4bb5966
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions mongodb/vibe/db/mongo/cursor.d
Original file line number Diff line number Diff line change
Expand Up @@ -121,23 +121,24 @@ struct MongoCursor(DocType = Bson) {
{
import core.memory : GC;

if( m_data && --m_data.refCount == 0 ){
try {
if (m_data && --m_data.refCount == 0) {
if (m_data.alive) {
// avoid InvalidMemoryOperation errors in case the cursor was
// leaked to the GC
if (m_data.alive && GC.inFinalizer) {
if(GC.inFinalizer) {
logError("MongoCursor instance that has not been fully processed leaked to the GC!");
try throw new Exception("");
catch (Exception e) {
try () @trusted { logError("%s", e.info); } ();
catch (Exception e2) logError(" ... failed to generate stack trace");
}
} else {
m_data.killCursors();
try m_data.killCursors();
catch (MongoException e) {
logWarn("MongoDB failed to kill cursors: %s", e.msg);
logDiagnostic("%s", (() @trusted => e.toString)());
}
}
} catch (MongoException e) {
logWarn("MongoDB failed to kill cursors: %s", e.msg);
logDiagnostic("%s", (() @trusted => e.toString)());
}
}
}
Expand Down

0 comments on commit 4bb5966

Please sign in to comment.