summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2013-05-16 02:10:59 -0700
committerPatrick Ohly <patrick.ohly@intel.com>2013-05-16 11:25:05 +0200
commit8dd516846af4a7a8ed839184b032ecac5c13c4da (patch)
tree0b8f7c98512f6923fe6a33efba47eec5c2c8f1d5
parent69b8780bde01d63f8c4981169b652fd17929c8ee (diff)
engine: free engine while still protected from signals
Explicitly free the engine before releasing our lock on shutdown signals. This prevents getting killed by a signal while we are still freeing resources, which can take some time when a background thread is involved (seen in some tests covering that).
-rw-r--r--src/syncevo/SyncContext.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/syncevo/SyncContext.cpp b/src/syncevo/SyncContext.cpp
index 9ceb2c6c..2f335824 100644
--- a/src/syncevo/SyncContext.cpp
+++ b/src/syncevo/SyncContext.cpp
@@ -3666,7 +3666,7 @@ SyncMLStatus SyncContext::doSync()
sysync::STEPCMD_CLIENTSTART;
SharedSession session = m_engine.OpenSession(m_sessionID);
SharedBuffer sendBuffer;
- SessionSentinel sessionSentinel(*this, session);
+ std::auto_ptr<SessionSentinel> sessionSentinel(new SessionSentinel(*this, session));
if (m_serverMode && !m_localSync) {
m_engine.WriteSyncMLBuffer(session,
@@ -4095,6 +4095,15 @@ SyncMLStatus SyncContext::doSync()
}
}
+ // Let session shut down before auto-destructing anything else
+ // (like our signal blocker). This may take a while, because it
+ // may involve shutting down the helper background thread which
+ // opened our local datastore.
+ SE_LOG_DEBUG(NULL, "closing session");
+ sessionSentinel.reset();
+ session.reset();
+ SE_LOG_DEBUG(NULL, "session closed");
+
return status;
}