diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-24 21:49:50 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-24 21:49:50 +0000 |
commit | 0036f08f0473a219cd9cace78901b6de9006f0b2 (patch) | |
tree | 18d43792ae89cf714a3da8bd2929ed5036ae2462 /net/http | |
parent | 575ce57a7ea86bbfdc2a03c41efb054d3e9129a8 (diff) | |
download | chromium_src-0036f08f0473a219cd9cace78901b6de9006f0b2.zip chromium_src-0036f08f0473a219cd9cace78901b6de9006f0b2.tar.gz chromium_src-0036f08f0473a219cd9cace78901b6de9006f0b2.tar.bz2 |
http_cache: Don't destroy an entry from the transaction destructor if
there is a task posted to process the next transaction.
Also, fix the check to determine the type of transaction to consider
writers that were converted to readers by the time the destructor runs.
I'm adding more checks to see if these were all the problems related to bug
3931.
B=4731
R=darin
Review URL: http://codereview.chromium.org/12608
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5938 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http')
-rw-r--r-- | net/http/http_cache.cc | 29 | ||||
-rw-r--r-- | net/http/http_cache.h | 1 |
2 files changed, 23 insertions, 7 deletions
diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc index 19b4657..3271035 100644 --- a/net/http/http_cache.cc +++ b/net/http/http_cache.cc @@ -319,12 +319,7 @@ class HttpCache::Transaction : public HttpTransaction { HttpCache::Transaction::~Transaction() { if (entry_) { - if (mode_ & WRITE) { - // Assume that this is not a successful write. - cache_->DoneWritingToEntry(entry_, false); - } else { - cache_->DoneReadingFromEntry(entry_, this); - } + cache_->DoneWithEntry(entry_, this); } else { cache_->RemovePendingTransaction(this); } @@ -1199,7 +1194,8 @@ void HttpCache::DeactivateEntry(ActiveEntry* entry) { ActiveEntriesMap::iterator it = active_entries_.find(entry->disk_entry->GetKey()); - CHECK(it != active_entries_.end() && it->second == entry); + CHECK(it != active_entries_.end()); + CHECK(it->second == entry); if (local_entry.will_process_pending_queue || local_entry.doomed || local_entry.writer || readers_size || pending_size) { @@ -1254,6 +1250,22 @@ int HttpCache::AddTransactionToEntry(ActiveEntry* entry, Transaction* trans) { return trans->EntryAvailable(entry); } +void HttpCache::DoneWithEntry(ActiveEntry* entry, Transaction* trans) { + // If we already posted a task to move on to the next transaction, there is + // nothing to cancel. + if (entry->will_process_pending_queue) + return; + + if (entry->writer) { + // TODO(rvargas): convert this to a DCHECK. + CHECK(trans == entry->writer); + // Assume that this is not a successful write. + DoneWritingToEntry(entry, false); + } else { + DoneReadingFromEntry(entry, trans); + } +} + void HttpCache::DoneWritingToEntry(ActiveEntry* entry, bool success) { DCHECK(entry->readers.empty()); @@ -1262,6 +1274,9 @@ void HttpCache::DoneWritingToEntry(ActiveEntry* entry, bool success) { if (success) { ProcessPendingQueue(entry); } else { + // TODO(rvargas): convert this to a DCHECK. + CHECK(!entry->will_process_pending_queue); + // We failed to create this entry. TransactionList pending_queue; pending_queue.swap(entry->pending_queue); diff --git a/net/http/http_cache.h b/net/http/http_cache.h index a2683f4..22f0754 100644 --- a/net/http/http_cache.h +++ b/net/http/http_cache.h @@ -129,6 +129,7 @@ class HttpCache : public HttpTransactionFactory { ActiveEntry* CreateEntry(const std::string& cache_key); void DestroyEntry(ActiveEntry* entry); int AddTransactionToEntry(ActiveEntry* entry, Transaction* trans); + void DoneWithEntry(ActiveEntry* entry, Transaction* trans); void DoneWritingToEntry(ActiveEntry* entry, bool success); void DoneReadingFromEntry(ActiveEntry* entry, Transaction* trans); void ConvertWriterToReader(ActiveEntry* entry); |