mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-17 05:09:53 +01:00
Database.setInboxGroup() doesn't require message lock.
This commit is contained in:
@@ -712,7 +712,7 @@ interface Database<T> {
|
|||||||
* Makes a group visible to the given contact, adds it to the contact's
|
* Makes a group visible to the given contact, adds it to the contact's
|
||||||
* subscriptions, and sets it as the inbox group for the contact.
|
* subscriptions, and sets it as the inbox group for the contact.
|
||||||
* <p>
|
* <p>
|
||||||
* Locking: contact read, message write, subscription write.
|
* Locking: subscription write.
|
||||||
*/
|
*/
|
||||||
public void setInboxGroup(T txn, ContactId c, Group g) throws DbException;
|
public void setInboxGroup(T txn, ContactId c, Group g) throws DbException;
|
||||||
|
|
||||||
|
|||||||
@@ -1770,25 +1770,20 @@ DatabaseCleaner.Callback {
|
|||||||
public void setInboxGroup(ContactId c, Group g) throws DbException {
|
public void setInboxGroup(ContactId c, Group g) throws DbException {
|
||||||
contactLock.readLock().lock();
|
contactLock.readLock().lock();
|
||||||
try {
|
try {
|
||||||
messageLock.writeLock().lock();
|
subscriptionLock.writeLock().lock();
|
||||||
try {
|
try {
|
||||||
subscriptionLock.writeLock().lock();
|
T txn = db.startTransaction();
|
||||||
try {
|
try {
|
||||||
T txn = db.startTransaction();
|
if(!db.containsContact(txn, c))
|
||||||
try {
|
throw new NoSuchContactException();
|
||||||
if(!db.containsContact(txn, c))
|
db.setInboxGroup(txn, c, g);
|
||||||
throw new NoSuchContactException();
|
db.commitTransaction(txn);
|
||||||
db.setInboxGroup(txn, c, g);
|
} catch(DbException e) {
|
||||||
db.commitTransaction(txn);
|
db.abortTransaction(txn);
|
||||||
} catch(DbException e) {
|
throw e;
|
||||||
db.abortTransaction(txn);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
subscriptionLock.writeLock().unlock();
|
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
messageLock.writeLock().unlock();
|
subscriptionLock.writeLock().unlock();
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
contactLock.readLock().unlock();
|
contactLock.readLock().unlock();
|
||||||
|
|||||||
Reference in New Issue
Block a user