Getting group message headers requires acquiring rating lock.

This commit is contained in:
akwizgran
2013-03-15 16:52:56 +00:00
parent 61cf16b808
commit a94867907f
2 changed files with 18 additions and 13 deletions

View File

@@ -277,7 +277,7 @@ interface Database<T> {
/**
* Returns the headers of all messages in the given group.
* <p>
* Locking: message read.
* Locking: message read, rating read.
*/
Collection<GroupMessageHeader> getMessageHeaders(T txn, GroupId g)
throws DbException;

View File

@@ -953,22 +953,27 @@ DatabaseCleaner.Callback {
throws DbException {
messageLock.readLock().lock();
try {
subscriptionLock.readLock().lock();
ratingLock.readLock().lock();
try {
T txn = db.startTransaction();
subscriptionLock.readLock().lock();
try {
if(!db.containsSubscription(txn, g))
throw new NoSuchSubscriptionException();
Collection<GroupMessageHeader> headers =
db.getMessageHeaders(txn, g);
db.commitTransaction(txn);
return headers;
} catch(DbException e) {
db.abortTransaction(txn);
throw e;
T txn = db.startTransaction();
try {
if(!db.containsSubscription(txn, g))
throw new NoSuchSubscriptionException();
Collection<GroupMessageHeader> headers =
db.getMessageHeaders(txn, g);
db.commitTransaction(txn);
return headers;
} catch(DbException e) {
db.abortTransaction(txn);
throw e;
}
} finally {
subscriptionLock.readLock().unlock();
}
} finally {
subscriptionLock.readLock().unlock();
ratingLock.readLock().unlock();
}
} finally {
messageLock.readLock().unlock();