mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-22 07:39:53 +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;
|
void open(boolean resume) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Waits for all open transactions to finish and closes the database.
|
* Prevents new transactions from starting, waits for all current
|
||||||
* <p>
|
* transactions to finish, and closes the database.
|
||||||
* Locking: all locks write.
|
|
||||||
*/
|
*/
|
||||||
void close() throws DbException;
|
void close() throws DbException;
|
||||||
|
|
||||||
|
|||||||
@@ -97,37 +97,7 @@ class ReadWriteLockDatabaseComponent<Txn> extends DatabaseComponentImpl<Txn> {
|
|||||||
|
|
||||||
public void close() throws DbException {
|
public void close() throws DbException {
|
||||||
cleaner.stopCleaning();
|
cleaner.stopCleaning();
|
||||||
contactLock.writeLock().lock();
|
db.close();
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContactId addContact(Map<String, Map<String, String>> transports)
|
public ContactId addContact(Map<String, Map<String, String>> transports)
|
||||||
|
|||||||
@@ -81,19 +81,7 @@ class SynchronizedDatabaseComponent<Txn> extends DatabaseComponentImpl<Txn> {
|
|||||||
|
|
||||||
public void close() throws DbException {
|
public void close() throws DbException {
|
||||||
cleaner.stopCleaning();
|
cleaner.stopCleaning();
|
||||||
synchronized(contactLock) {
|
db.close();
|
||||||
synchronized(messageLock) {
|
|
||||||
synchronized(messageStatusLock) {
|
|
||||||
synchronized(ratingLock) {
|
|
||||||
synchronized(subscriptionLock) {
|
|
||||||
synchronized(transportLock) {
|
|
||||||
db.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContactId addContact(Map<String, Map<String, String>> transports)
|
public ContactId addContact(Map<String, Map<String, String>> transports)
|
||||||
|
|||||||
Reference in New Issue
Block a user