Skip to content
Snippets Groups Projects
Unverified Commit 0ae69b3d authored by Richard Cordovano's avatar Richard Cordovano Committed by GitHub
Browse files

Merge pull request #2389 from raman-bt/casedbtrans-lock-connection-order

When creating a CaseDBTransaction - change the order in which we acqu…
parents 8c3527b2 257467db
No related branches found
No related tags found
No related merge requests found
......@@ -2718,7 +2718,7 @@ public String getBackupDatabasePath() {
* @throws TskCoreException
*/
public CaseDbTransaction beginTransaction() throws TskCoreException {
return new CaseDbTransaction(this, connections.getConnection());
return new CaseDbTransaction(this);
}
 
/**
......@@ -13093,18 +13093,21 @@ public static final class CaseDbTransaction {
private static Set<Long> threadsWithOpenTransaction = new HashSet<>();
private static final Object threadsWithOpenTransactionLock = new Object();
 
private CaseDbTransaction(SleuthkitCase sleuthkitCase, CaseDbConnection connection) throws TskCoreException {
this.connection = connection;
private CaseDbTransaction(SleuthkitCase sleuthkitCase) throws TskCoreException {
this.sleuthkitCase = sleuthkitCase;
sleuthkitCase.acquireSingleUserCaseWriteLock();
this.connection = sleuthkitCase.getConnection();
try {
synchronized (threadsWithOpenTransactionLock) {
this.connection.beginTransaction();
threadsWithOpenTransaction.add(Thread.currentThread().getId());
}
} catch (SQLException ex) {
sleuthkitCase.releaseSingleUserCaseWriteLock();
throw new TskCoreException("Failed to create transaction on case database", ex);
}
sleuthkitCase.acquireSingleUserCaseWriteLock();
}
 
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment