Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(347)

Unified Diff: net/http/http_cache.cc

Issue 11787007: Race Create vs SendRequest on cache misses. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: lose a race Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/disk_cache/pending_create_entry.cc ('k') | net/net.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_cache.cc
diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc
index d7461193762e31baf6c9c7608f1cc7ce345b9235..1a7e492c24b4f0ad2dd30a8b8cf2e0ad67d4f08a 100644
--- a/net/http/http_cache.cc
+++ b/net/http/http_cache.cc
@@ -30,6 +30,7 @@
#include "net/base/net_errors.h"
#include "net/base/upload_data_stream.h"
#include "net/disk_cache/disk_cache.h"
+#include "net/disk_cache/pending_create_entry.h"
#include "net/http/http_cache_transaction.h"
#include "net/http/http_network_layer.h"
#include "net/http/http_network_session.h"
@@ -711,7 +712,9 @@ int HttpCache::OpenEntry(const std::string& key, ActiveEntry** entry,
int HttpCache::CreateEntry(const std::string& key, ActiveEntry** entry,
Transaction* trans) {
- DCHECK(!FindActiveEntry(key));
+ if (FindActiveEntry(key)) {
+ return ERR_CACHE_RACE;
+ }
WorkItem* item = new WorkItem(WI_CREATE_ENTRY, trans, entry);
PendingOp* pending_op = GetPendingOp(key);
@@ -726,8 +729,8 @@ int HttpCache::CreateEntry(const std::string& key, ActiveEntry** entry,
pending_op->callback = base::Bind(&HttpCache::OnPendingOpComplete,
AsWeakPtr(), pending_op);
- int rv = disk_cache_->CreateEntry(key, &(pending_op->disk_entry),
- pending_op->callback);
+ int rv = disk_cache::PendingCreateEntry(disk_cache_.get(), key,
+ &(pending_op->disk_entry));
if (rv != ERR_IO_PENDING) {
item->ClearTransaction();
pending_op->callback.Run(rv);
« no previous file with comments | « net/disk_cache/pending_create_entry.cc ('k') | net/net.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698