From 53f4826c9fe6bea1718a499dc686f26dbf24ab50 Mon Sep 17 00:00:00 2001 From: "davidben@chromium.org" Date: Fri, 27 Aug 2010 01:29:28 +0000 Subject: Move the SingletonSocket to a temporary directory This is to workaround problems on certain network filesystems (notably AFS) which do not support Unix domain sockets. We move the sockets into a temporary folder and symlink. To avoid the possibility of a dangling link to a missing (and later intercepted) remote directory, we create and check cookie files and rely on the stickiness of /tmp/ to avoid a race condition in the check. R=mattm BUG=44606 TEST=ProcessSingletonLinuxTest.* Review URL: http://codereview.chromium.org/2838034 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57623 0039d316-1c4b-4281-b951-d872f2087c98 --- base/scoped_temp_dir.cc | 9 +++++++-- base/scoped_temp_dir.h | 5 ++++- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'base') diff --git a/base/scoped_temp_dir.cc b/base/scoped_temp_dir.cc index 958dcbc..a510ddf 100644 --- a/base/scoped_temp_dir.cc +++ b/base/scoped_temp_dir.cc @@ -11,8 +11,7 @@ ScopedTempDir::ScopedTempDir() { } ScopedTempDir::~ScopedTempDir() { - if (!path_.empty() && !file_util::Delete(path_, true)) - LOG(ERROR) << "ScopedTempDir unable to delete " << path_.value(); + Delete(); } bool ScopedTempDir::CreateUniqueTempDir() { @@ -50,6 +49,12 @@ bool ScopedTempDir::Set(const FilePath& path) { return true; } +void ScopedTempDir::Delete() { + if (!path_.empty() && !file_util::Delete(path_, true)) + LOG(ERROR) << "ScopedTempDir unable to delete " << path_.value(); + path_.clear(); +} + FilePath ScopedTempDir::Take() { FilePath ret = path_; path_ = FilePath(); diff --git a/base/scoped_temp_dir.h b/base/scoped_temp_dir.h index 702c2bc..66d52f6 100644 --- a/base/scoped_temp_dir.h +++ b/base/scoped_temp_dir.h @@ -19,7 +19,7 @@ class ScopedTempDir { // No directory is owned/created initially. ScopedTempDir(); - // Recursively delete path_ + // Recursively delete path. ~ScopedTempDir(); // Creates a unique directory in TempPath, and takes ownership of it. @@ -33,6 +33,9 @@ class ScopedTempDir { // Don't call multiple times unless Take() has been called first. bool Set(const FilePath& path); + // Deletes the temporary directory wrapped by this object. + void Delete(); + // Caller takes ownership of the temporary directory so it won't be destroyed // when this object goes out of scope. FilePath Take(); -- cgit v1.1