mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-11 18:29:05 +01:00
It's not necessary to acquire all locks before closing the database,
since Database.close() prevents new transactions from starting anyway.
This commit is contained in:
@@ -48,9 +48,8 @@ interface Database<T> {
|
||||
void open(boolean resume) throws DbException;
|
||||
|
||||
/**
|
||||
* Waits for all open transactions to finish and closes the database.
|
||||
* <p>
|
||||
* Locking: all locks write.
|
||||
* Prevents new transactions from starting, waits for all current
|
||||
* transactions to finish, and closes the database.
|
||||
*/
|
||||
void close() throws DbException;
|
||||
|
||||
|
||||
@@ -97,37 +97,7 @@ class ReadWriteLockDatabaseComponent<Txn> extends DatabaseComponentImpl<Txn> {
|
||||
|
||||
public void close() throws DbException {
|
||||
cleaner.stopCleaning();
|
||||
contactLock.writeLock().lock();
|
||||
try {
|
||||
messageLock.writeLock().lock();
|
||||
try {
|
||||
messageStatusLock.writeLock().lock();
|
||||
try {
|
||||
ratingLock.writeLock().lock();
|
||||
try {
|
||||
subscriptionLock.writeLock().lock();
|
||||
try {
|
||||
transportLock.writeLock().lock();
|
||||
try {
|
||||
db.close();
|
||||
} finally {
|
||||
transportLock.writeLock().unlock();
|
||||
}
|
||||
} finally {
|
||||
subscriptionLock.writeLock().unlock();
|
||||
}
|
||||
} finally {
|
||||
ratingLock.writeLock().unlock();
|
||||
}
|
||||
} finally {
|
||||
messageStatusLock.writeLock().unlock();
|
||||
}
|
||||
} finally {
|
||||
messageLock.writeLock().unlock();
|
||||
}
|
||||
} finally {
|
||||
contactLock.writeLock().unlock();
|
||||
}
|
||||
db.close();
|
||||
}
|
||||
|
||||
public ContactId addContact(Map<String, Map<String, String>> transports)
|
||||
|
||||
@@ -81,19 +81,7 @@ class SynchronizedDatabaseComponent<Txn> extends DatabaseComponentImpl<Txn> {
|
||||
|
||||
public void close() throws DbException {
|
||||
cleaner.stopCleaning();
|
||||
synchronized(contactLock) {
|
||||
synchronized(messageLock) {
|
||||
synchronized(messageStatusLock) {
|
||||
synchronized(ratingLock) {
|
||||
synchronized(subscriptionLock) {
|
||||
synchronized(transportLock) {
|
||||
db.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
db.close();
|
||||
}
|
||||
|
||||
public ContactId addContact(Map<String, Map<String, String>> transports)
|
||||
|
||||
Reference in New Issue
Block a user