Skip to content

Commit

Permalink
Static destruction order fix SERVER-1276
Browse files Browse the repository at this point in the history
  • Loading branch information
RedBeard0531 committed Jul 1, 2010
1 parent aa7aeab commit ae2aa8a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions util/message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,10 @@ namespace mongo {
};

class Ports {
set<MessagingPort*>& ports;
set<MessagingPort*> 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<MessagingPort*>()) ), m("Ports") {}
Ports() : ports(), m("Ports") {}
void closeAll() { \
scoped_lock bl(m);
for ( set<MessagingPort*>::iterator i = ports.begin(); i != ports.end(); i++ )
Expand All @@ -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());



Expand Down

0 comments on commit ae2aa8a

Please sign in to comment.