summaryrefslogtreecommitdiff
path: root/mobicore
diff options
context:
space:
mode:
authorOana Medvesan <medvesan.oana@gmail.com>2015-08-04 11:19:57 +0200
committerAndreas Schneider <asn@cryptomilk.org>2017-02-12 19:28:05 +0100
commitcd93ec98b043012ca0e2e18fc2211300bca0e0c0 (patch)
tree8e1160e16a378589075e57c81cae78b5e4b4728f /mobicore
parentdab4f12a367d5be64dc8db959155e60e934d8e40 (diff)
downloadandroid_hardware_samsung_slsi_exynos5430-cd93ec98b043012ca0e2e18fc2211300bca0e0c0.tar.gz
android_hardware_samsung_slsi_exynos5430-cd93ec98b043012ca0e2e18fc2211300bca0e0c0.tar.xz
android_hardware_samsung_slsi_exynos5430-cd93ec98b043012ca0e2e18fc2211300bca0e0c0.zip
tbase-301B: fix closing of sessions in the daemon; bug was craeting a daemon crash on Android M
Signed-off-by: Oana Medvesan <medvesan.oana@gmail.com>
Diffstat (limited to 'mobicore')
-rw-r--r--mobicore/MobiCoreDriverLib/Daemon/Device/MobiCoreDevice.cpp54
-rw-r--r--mobicore/MobiCoreDriverLib/buildTag.h2
2 files changed, 16 insertions, 40 deletions
diff --git a/mobicore/MobiCoreDriverLib/Daemon/Device/MobiCoreDevice.cpp b/mobicore/MobiCoreDriverLib/Daemon/Device/MobiCoreDevice.cpp
index 64b8e58..3e86dcb 100644
--- a/mobicore/MobiCoreDriverLib/Daemon/Device/MobiCoreDevice.cpp
+++ b/mobicore/MobiCoreDriverLib/Daemon/Device/MobiCoreDevice.cpp
@@ -233,50 +233,26 @@ void MobiCoreDevice::close(
// TA, so we want to terminate the TA first and then the driver. This may
// make this a bit easier for everbody.
- trustletSessionList_t::reverse_iterator revIt = trustletSessions.rbegin();
- while (revIt != trustletSessions.rend())
+ // Cannot lock list as we need to receive notifications, but it may change, so search under lock
+ trustletSessionList_t sessions_list;
+ mutex_tslist.lock();
+ for (trustletSessionList_t::reverse_iterator revIt = trustletSessions.rbegin(); revIt != trustletSessions.rend(); revIt++)
{
- TrustletSession *session = *revIt;
-
- // wiredness of reverse iterators
- // * is is incremented to get the next lowe element
- // * to delete something from the list, we need the "normal" iterator.
- // This is simpy "one off" the current revIt. So we can savely use
- // the increment below in both cases.
- revIt++;
-
- if (session->deviceConnection == connection)
- {
- // close session, log any error but ignore it.
- //mcResult_t mcRet = closeSessionInternal(session);
- mcResult_t mcRet = closeSession(connection, session->sessionId);
- if (mcRet != MC_MCP_RET_OK) {
- LOG_I("device closeSession failed with %d", mcRet);
- }
+ if ((*revIt)->deviceConnection == connection) {
+ LOG_I("MobiCoreDevice::close found a session %p", *revIt);
- // removing an element from the list it tricky. Convert the revIt
- // to a "normal" iterator. Remember here that the revIt is one off,
- // but we have done an increment above, so we are fine here. So
- // after we have the normal iterator, ude it to delete and then
- // convert the returned iterator back to a reverse iterator, which
- // we will use for the loop.
- //trustletSessionIterator_t it = revIt.base();
- //it = trustletSessions.erase(it); // delete
- //revIt = trustletSessionList_t::reverse_iterator(it);
-
- // free object
- //delete session;
+ sessions_list.push_back(*revIt);
+ break;
}
}
+ mutex_tslist.unlock();
- // Leave critical section
- mutex.unlock();
-
- // After the trustlet is done make sure to tell the driver to cleanup
- // all the orphaned drivers
- //cleanupWsmL2();
-
-
+ for (trustletSessionList_t::iterator it = sessions_list.begin(); it != sessions_list.end(); it++) {
+ mcResult_t mcRet = closeSession(connection, (*it)->sessionId);
+ if (mcRet != MC_MCP_RET_OK) {
+ LOG_I("device closeSession failed for %p with %d", *it, mcRet);
+ }
+ }
connection->connectionData = NULL;
diff --git a/mobicore/MobiCoreDriverLib/buildTag.h b/mobicore/MobiCoreDriverLib/buildTag.h
index 10fbb8f..e173604 100644
--- a/mobicore/MobiCoreDriverLib/buildTag.h
+++ b/mobicore/MobiCoreDriverLib/buildTag.h
@@ -30,4 +30,4 @@
*/
/** Build tag created during build by /data/buildserver/jenkins/workspace/CustomerPackage-QC-MSM8916-Branch-rel_t-base-301B-V001_qc/dev/components/MobiCoreDriver/Linux/Daemon/../../../../../build/tools/Scripts/setBuildTag.sh. */
#define MOBICORE_COMPONENT_BUILD_TAG \
- "t-base-QC-MSM8916-Android-301B-V003-36_36"
+ "t-base-QC-MSM8916-Android-301B-V003-37_37"