From 8333732ae08ccab0bd9d3916dc4796c1b35800a2 Mon Sep 17 00:00:00 2001 From: "rvargas@google.com" Date: Wed, 3 Dec 2008 23:55:52 +0000 Subject: upgrade cache tool: Improve the handling of errors so that we ignore as much as possible without aborting the whole process. R=nsylvain Review URL: http://codereview.chromium.org/12925 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6334 0039d316-1c4b-4281-b951-d872f2087c98 --- net/tools/dump_cache/upgrade.cc | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'net') diff --git a/net/tools/dump_cache/upgrade.cc b/net/tools/dump_cache/upgrade.cc index 1495b95..c715f14 100644 --- a/net/tools/dump_cache/upgrade.cc +++ b/net/tools/dump_cache/upgrade.cc @@ -331,17 +331,22 @@ void MasterSM::DoGetKey(int bytes_read) { DEBUGMSG("Master DoGetKey\n"); DCHECK(state_ == MASTER_GET_KEY); DCHECK(input_->msg.command == GET_KEY); - if (input_->msg.result == RESULT_NAME_OVERFLOW) + if (input_->msg.result == RESULT_NAME_OVERFLOW) { // The key is too long. Just move on. + printf("Skipping entry (name too long)\n"); return SendGetPrevEntry(); + } if (input_->msg.result != RESULT_OK) return Fail(); std::string key(input_->buffer); DCHECK(key.size() == input_->msg.buffer_bytes - 1); - if (!cache_->CreateEntry(key, reinterpret_cast(&entry_))) - return Fail(); + if (!cache_->CreateEntry(key, + reinterpret_cast(&entry_))) { + printf("Skipping entry \"%s\" (name conflict!)\n", key.c_str()); + return SendGetPrevEntry(); + } if (key.size() < 60) { DEBUGMSG("Entry \"%s\" created\n", key.c_str()); @@ -433,6 +438,12 @@ void MasterSM::DoReadData(int bytes_read) { return Fail(); int read_size = input_->msg.buffer_bytes; + if (!read_size) { + printf("Read failed, entry \"%s\" truncated!\n", entry_->GetKey().c_str()); + bytes_remaining_ = 0; + return SendReadData(); + } + if (read_size != entry_->WriteData(stream_, offset_, input_->buffer, read_size, NULL, false)) return Fail(); -- cgit v1.1