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());