From ae2aa8a24552ab035ead84eb49fcc17270beb522 Mon Sep 17 00:00:00 2001 From: Mathias Stearn Date: Thu, 1 Jul 2010 16:59:59 -0400 Subject: [PATCH] Static destruction order fix SERVER-1276 --- util/message.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/util/message.cpp b/util/message.cpp index 15b73a1c69e28..61a4175b410ae 100644 --- a/util/message.cpp +++ b/util/message.cpp @@ -251,12 +251,10 @@ namespace mongo { }; class Ports { - set& ports; + set ports; mongo::mutex m; public: - // we "new" this so it is still be around when other automatic global vars - // are being destructed during termination. - Ports() : ports( *(new set()) ), m("Ports") {} + Ports() : ports(), m("Ports") {} void closeAll() { \ scoped_lock bl(m); for ( set::iterator i = ports.begin(); i != ports.end(); i++ ) @@ -270,7 +268,11 @@ namespace mongo { scoped_lock bl(m); ports.erase(p); } - } ports; + }; + + // we "new" this so it is still be around when other automatic global vars + // are being destructed during termination. + Ports& ports = *(new Ports());