Skip to content

Commit 2dc6c7f

Browse files
author
Tom Taylor
committed
Remove deleted pdu items from the updated cache
When pdu's are removed from the PduCache, make sure we remove them from the list of pdu's currently being updated as well. Change-Id: I45dde4a09d74019a344fca31e3926b1ece6c393d
1 parent cbd01c3 commit 2dc6c7f

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

core/java/com/google/android/mms/pdu/PduPersister.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,9 @@ public GenericPdu load(Uri uri) throws MmsException {
513513
PduCacheEntry cacheEntry;
514514
synchronized(PDU_CACHE_INSTANCE) {
515515
if (PDU_CACHE_INSTANCE.isUpdating(uri)) {
516+
if (LOCAL_LOGV) {
517+
Log.v(TAG, "load: " + uri + " blocked by isUpdating()");
518+
}
516519
try {
517520
PDU_CACHE_INSTANCE.wait();
518521
} catch (InterruptedException e) {
@@ -840,6 +843,9 @@ public void updateHeaders(Uri uri, SendReq sendReq) {
840843
// If the cache item is getting updated, wait until it's done updating before
841844
// purging it.
842845
if (PDU_CACHE_INSTANCE.isUpdating(uri)) {
846+
if (LOCAL_LOGV) {
847+
Log.v(TAG, "updateHeaders: " + uri + " blocked by isUpdating()");
848+
}
843849
try {
844850
PDU_CACHE_INSTANCE.wait();
845851
} catch (InterruptedException e) {
@@ -1002,6 +1008,9 @@ public void updateParts(Uri uri, PduBody body)
10021008
PduCacheEntry cacheEntry;
10031009
synchronized(PDU_CACHE_INSTANCE) {
10041010
if (PDU_CACHE_INSTANCE.isUpdating(uri)) {
1011+
if (LOCAL_LOGV) {
1012+
Log.v(TAG, "updateParts: " + uri + " blocked by isUpdating()");
1013+
}
10051014
try {
10061015
PDU_CACHE_INSTANCE.wait();
10071016
} catch (InterruptedException e) {
@@ -1097,6 +1106,9 @@ public Uri persist(GenericPdu pdu, Uri uri) throws MmsException {
10971106
// If the cache item is getting updated, wait until it's done updating before
10981107
// purging it.
10991108
if (PDU_CACHE_INSTANCE.isUpdating(uri)) {
1109+
if (LOCAL_LOGV) {
1110+
Log.v(TAG, "persist: " + uri + " blocked by isUpdating()");
1111+
}
11001112
try {
11011113
PDU_CACHE_INSTANCE.wait();
11021114
} catch (InterruptedException e) {

core/java/com/google/android/mms/util/PduCache.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ synchronized public PduCacheEntry purge(Uri uri) {
161161
}
162162

163163
private PduCacheEntry purgeSingleEntry(Uri key) {
164+
mUpdating.remove(key);
164165
PduCacheEntry entry = super.purge(key);
165166
if (entry != null) {
166167
removeFromThreads(key, entry);
@@ -176,6 +177,7 @@ synchronized public void purgeAll() {
176177

177178
mMessageBoxes.clear();
178179
mThreads.clear();
180+
mUpdating.clear();
179181
}
180182

181183
/**
@@ -216,6 +218,7 @@ private void purgeByMessageBox(Integer msgBoxId) {
216218
HashSet<Uri> msgBox = mMessageBoxes.remove(msgBoxId);
217219
if (msgBox != null) {
218220
for (Uri key : msgBox) {
221+
mUpdating.remove(key);
219222
PduCacheEntry entry = super.purge(key);
220223
if (entry != null) {
221224
removeFromThreads(key, entry);
@@ -240,6 +243,7 @@ private void purgeByThreadId(long threadId) {
240243
HashSet<Uri> thread = mThreads.remove(threadId);
241244
if (thread != null) {
242245
for (Uri key : thread) {
246+
mUpdating.remove(key);
243247
PduCacheEntry entry = super.purge(key);
244248
if (entry != null) {
245249
removeFromMessageBoxes(key, entry);

0 commit comments

Comments
 (0)