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

Unified Diff: src/platform/update_engine/download_action.cc

Issue 1881001: AU: Many minor cleanup changes (Closed) Base URL: ssh://git@chromiumos-git/chromeos
Patch Set: fixes for review Created 10 years, 8 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 | « src/platform/installer/chromeos-postinst ('k') | src/platform/update_engine/main.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/platform/update_engine/download_action.cc
diff --git a/src/platform/update_engine/download_action.cc b/src/platform/update_engine/download_action.cc
index 53878213c605d90a2c35256a1c18f883d3c64b20..eee25ccfd241cb1f8a9447325ee060c4c259167b 100644
--- a/src/platform/update_engine/download_action.cc
+++ b/src/platform/update_engine/download_action.cc
@@ -5,10 +5,15 @@
#include "update_engine/download_action.h"
#include <errno.h>
#include <algorithm>
+#include <string>
+#include <vector>
#include <glib.h>
#include "update_engine/action_pipe.h"
+#include "update_engine/subprocess.h"
using std::min;
+using std::string;
+using std::vector;
namespace chromeos_update_engine {
@@ -84,6 +89,22 @@ void DownloadAction::ReceivedBytes(HttpFetcher *fetcher,
omaha_hash_calculator_.Update(bytes, length);
}
+namespace {
+void FlushLinuxCaches() {
+ vector<string> command;
+ command.push_back("/bin/sync");
+ int rc;
+ LOG(INFO) << "FlushLinuxCaches/sync...";
+ Subprocess::SynchronousExec(command, &rc);
+ LOG(INFO) << "FlushLinuxCaches/drop_caches...";
+
+ const char* const drop_cmd = "3\n";
+ utils::WriteFile("/proc/sys/vm/drop_caches", drop_cmd, strlen(drop_cmd));
+
+ LOG(INFO) << "FlushLinuxCaches done.";
+}
+}
+
void DownloadAction::TransferComplete(HttpFetcher *fetcher, bool successful) {
if (writer_) {
CHECK_EQ(writer_->Close(), 0) << errno;
@@ -99,6 +120,8 @@ void DownloadAction::TransferComplete(HttpFetcher *fetcher, bool successful) {
successful = false;
}
}
+
+ FlushLinuxCaches();
// Write the path to the output pipe if we're successful
if (successful && HasOutputPipe())
« no previous file with comments | « src/platform/installer/chromeos-postinst ('k') | src/platform/update_engine/main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698