clean up ConnectionRepository on exit

This commit is contained in:
David Rose 2009-12-05 07:17:53 +00:00
parent 7ed5437e15
commit 72da0ee5f1
4 changed files with 24 additions and 4 deletions

View File

@ -51,7 +51,9 @@ class ConnectionRepository(
DoInterestManager.__init__(self)
DoCollectionManager.__init__(self)
self.setPythonRepository(self)
base.finalExitCallbacks.append(self.shutdown)
self.config = config
if self.config.GetBool('verbose-repository'):
@ -591,6 +593,7 @@ class ConnectionRepository(
def readerPollUntilEmpty(self, task):
while self.readerPollOnce():
pass
Thread.forceYield()
return Task.cont
def readerPollOnce(self):

View File

@ -665,6 +665,22 @@ disconnect() {
_simulated_disconnect = false;
}
////////////////////////////////////////////////////////////////////
// Function: CConnectionRepository::shutdown
// Access: Published
// Description: May be called at application shutdown to ensure all
// threads are cleaned up.
////////////////////////////////////////////////////////////////////
void CConnectionRepository::
shutdown() {
disconnect();
#ifdef HAVE_NET
_cw.shutdown();
_qcr.shutdown();
#endif // HAVE_NET
}
////////////////////////////////////////////////////////////////////
// Function: CConnectionRepository::do_check_datagram
// Access: Private

View File

@ -144,6 +144,7 @@ PUBLISHED:
bool flush();
void disconnect();
void shutdown();
INLINE void set_simulated_disconnect(bool simulated_disconnect);
INLINE bool get_simulated_disconnect() const;

View File

@ -429,6 +429,9 @@ class ShowBase(DirectObject.DirectObject):
This function is designed to be safe to call multiple times."""
for cb in self.finalExitCallbacks:
cb()
# [gjeon] restore sticky key settings
if self.config.GetBool('disable-sticky-keys', 0):
allowAccessibilityShortcutKeys(True)
@ -457,9 +460,6 @@ class ShowBase(DirectObject.DirectObject):
vfs = VirtualFileSystem.getGlobalPtr()
vfs.unmountAll()
for cb in self.finalExitCallbacks:
cb()
def exitfunc(self):