diff options
author | erikchen <erikchen@chromium.org> | 2015-06-18 14:48:33 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-18 21:49:01 +0000 |
commit | 893dadc6e82a64c8135b6f4852ee0960ea62e4a5 (patch) | |
tree | 9fc20294e440892646025b431e3d6f2f4f42b1f5 /base/memory/shared_memory_posix.cc | |
parent | fb47c8f3ddbd1a412a18826c700d6526b345bb4e (diff) | |
download | chromium_src-893dadc6e82a64c8135b6f4852ee0960ea62e4a5.zip chromium_src-893dadc6e82a64c8135b6f4852ee0960ea62e4a5.tar.gz chromium_src-893dadc6e82a64c8135b6f4852ee0960ea62e4a5.tar.bz2 |
Remove unused locking functionality from base::SharedMemory.
The only existing consumers of the locking functionality were two unit tests for
SharedMemory.
The first unit test only tested the locking functionality across threads, so I
removed the test.
The second unit test was intended to test cross-process functionality of
base::SharedMemory, and used the locking functionality as a synchronization
method between processes. I rewrote the test to actually test Shared Memory
functionality, as the original test only tested synchronization between
processes, and would have succeeded even if Shared Memory didn't work. I
replaced the synchronization with compare and swap operations.
BUG=466437, 345734
Review URL: https://codereview.chromium.org/1167863002
Cr-Commit-Position: refs/heads/master@{#335135}
Diffstat (limited to 'base/memory/shared_memory_posix.cc')
-rw-r--r-- | base/memory/shared_memory_posix.cc | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/base/memory/shared_memory_posix.cc b/base/memory/shared_memory_posix.cc index 35d746e..8aaa9ce 100644 --- a/base/memory/shared_memory_posix.cc +++ b/base/memory/shared_memory_posix.cc @@ -4,16 +4,13 @@ #include "base/memory/shared_memory.h" -#include <errno.h> #include <fcntl.h> #include <sys/mman.h> #include <sys/stat.h> -#include <sys/types.h> #include <unistd.h> #include "base/files/file_util.h" #include "base/files/scoped_file.h" -#include "base/lazy_instance.h" #include "base/logging.h" #include "base/posix/eintr_wrapper.h" #include "base/posix/safe_strerror.h" @@ -21,9 +18,6 @@ #include "base/profiler/scoped_tracker.h" #include "base/scoped_generic.h" #include "base/strings/utf_string_conversions.h" -#include "base/synchronization/lock.h" -#include "base/threading/platform_thread.h" -#include "base/threading/thread_restrictions.h" #if defined(OS_MACOSX) #include "base/mac/foundation_util.h" @@ -38,8 +32,6 @@ namespace base { namespace { -LazyInstance<Lock>::Leaky g_thread_lock_ = LAZY_INSTANCE_INITIALIZER; - struct ScopedPathUnlinkerTraits { static FilePath* InvalidValue() { return nullptr; } @@ -414,16 +406,6 @@ void SharedMemory::Close() { } } -void SharedMemory::LockDeprecated() { - g_thread_lock_.Get().Acquire(); - LockOrUnlockCommon(F_LOCK); -} - -void SharedMemory::UnlockDeprecated() { - LockOrUnlockCommon(F_ULOCK); - g_thread_lock_.Get().Release(); -} - #if !defined(OS_ANDROID) bool SharedMemory::PrepareMapFile(ScopedFILE fp, ScopedFD readonly_fd) { DCHECK_EQ(-1, mapped_file_); @@ -491,25 +473,6 @@ bool SharedMemory::FilePathForMemoryName(const std::string& mem_name, } #endif // !defined(OS_ANDROID) -void SharedMemory::LockOrUnlockCommon(int function) { - DCHECK_GE(mapped_file_, 0); - while (lockf(mapped_file_, function, 0) < 0) { - if (errno == EINTR) { - continue; - } else if (errno == ENOLCK) { - // temporary kernel resource exaustion - base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(500)); - continue; - } else { - NOTREACHED() << "lockf() failed." - << " function:" << function - << " fd:" << mapped_file_ - << " errno:" << errno - << " msg:" << base::safe_strerror(errno); - } - } -} - bool SharedMemory::ShareToProcessCommon(ProcessHandle process, SharedMemoryHandle* new_handle, bool close_self, |