Commit c79ccfac authored by Leonid Baraz's avatar Leonid Baraz Committed by Chromium LUCI CQ

Fix bug in reservation monitoring.

In ScopedReservation destructor did Reserve instead of Discard!
This is now fixed; tests will be added separately.

Bug: b:159361496
Change-Id: I6cf8932ff113e53a6c15564675135406d81fccc0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2640820
Commit-Queue: Leonid Baraz <lbaraz@chromium.org>
Commit-Queue: Zach Trudo <zatrudo@google.com>
Auto-Submit: Leonid Baraz <lbaraz@chromium.org>
Reviewed-by: default avatarZach Trudo <zatrudo@google.com>
Cr-Commit-Position: refs/heads/master@{#845373}
parent e2de939b
......@@ -27,7 +27,7 @@ bool ScopedReservation::reserved() const {
ScopedReservation::~ScopedReservation() {
if (reserved()) {
resource_interface_->Reserve(size_.value());
resource_interface_->Discard(size_.value());
}
}
......
......@@ -139,10 +139,8 @@ StorageQueue::~StorageQueue() {
// Stop upload timer.
upload_timer_.AbandonAndStop();
// CLose all opened files.
for (auto& file : files_) {
file.second->Close();
}
// Close all opened files.
files_.clear();
}
Status StorageQueue::Init() {
......@@ -1318,6 +1316,7 @@ StorageQueue::SingleFile::SingleFile(const base::FilePath& filename,
: filename_(filename), size_(size) {}
StorageQueue::SingleFile::~SingleFile() {
Close();
handle_.reset();
}
......@@ -1355,8 +1354,10 @@ void StorageQueue::SingleFile::Close() {
}
handle_.reset();
is_readonly_ = base::nullopt;
buffer_.reset();
GetMemoryResource()->Discard(buffer_size_);
if (buffer_) {
buffer_.reset();
GetMemoryResource()->Discard(buffer_size_);
}
}
Status StorageQueue::SingleFile::Delete() {
......
......@@ -15,7 +15,6 @@
#include "base/optional.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/synchronization/waitable_event.h"
#include "base/test/task_environment.h"
#include "chrome/browser/policy/messaging_layer/encryption/test_encryption_module.h"
#include "chrome/browser/policy/messaging_layer/storage/storage_configuration.h"
......
......@@ -13,7 +13,6 @@
#include "base/sequenced_task_runner.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/synchronization/waitable_event.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "chrome/browser/policy/messaging_layer/encryption/decryption.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment