summaryrefslogtreecommitdiffstats
path: root/chrome/common/multi_process_lock_linux.cc
diff options
context:
space:
mode:
authorrobert.nagy@gmail.com <robert.nagy@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-11 19:56:35 +0000
committerrobert.nagy@gmail.com <robert.nagy@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-11 19:56:35 +0000
commite60c023a07150052e4aefe6fd95ce5d09fc8767a (patch)
tree94577597f228dd8dce7e5aed8d0f98c3fe2487b8 /chrome/common/multi_process_lock_linux.cc
parent10d7c0e4a5e5e15c0574b9ac4a94a93605c733bd (diff)
downloadchromium_src-e60c023a07150052e4aefe6fd95ce5d09fc8767a.zip
chromium_src-e60c023a07150052e4aefe6fd95ce5d09fc8767a.tar.gz
chromium_src-e60c023a07150052e4aefe6fd95ce5d09fc8767a.tar.bz2
share all the needed linux code with OpenBSD in chrome and content
disabled code for OpenBSD: - AdjustRendererOOMScore() - SECCOMP_SANDBOX BUG= TEST=compile Review URL: http://codereview.chromium.org/8341052 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109679 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/multi_process_lock_linux.cc')
-rw-r--r--chrome/common/multi_process_lock_linux.cc23
1 files changed, 10 insertions, 13 deletions
diff --git a/chrome/common/multi_process_lock_linux.cc b/chrome/common/multi_process_lock_linux.cc
index c5b70a4..f610237 100644
--- a/chrome/common/multi_process_lock_linux.cc
+++ b/chrome/common/multi_process_lock_linux.cc
@@ -24,33 +24,30 @@ class MultiProcessLockLinux : public MultiProcessLock {
}
virtual bool TryLock() {
+ struct sockaddr_un address;
+
+ // +1 for terminator, +1 for 0 in position 0 that makes it an
+ // abstract named socket.
+ const size_t max_len = sizeof(address.sun_path) - 2;
+
if (fd_ != -1) {
DLOG(ERROR) << "MultiProcessLock is already locked - " << name_;
return true;
}
- if (name_.length() > MULTI_PROCESS_LOCK_NAME_MAX_LEN) {
+ if (name_.length() > max_len) {
LOG(ERROR) << "Socket name too long (" << name_.length()
- << " > " << MULTI_PROCESS_LOCK_NAME_MAX_LEN << ") - " << name_;
+ << " > " << max_len << ") - " << name_;
return false;
}
- struct sockaddr_un address;
-
- // +1 for terminator, +1 for 0 in position 0 that makes it an
- // abstract named socket.
- // If this assert fails it is because sockaddr_un.sun_path size has been
- // redefined and MULTI_PROCESS_LOCK_NAME_MAX_LEN can change accordingly.
- COMPILE_ASSERT(sizeof(address.sun_path)
- == MULTI_PROCESS_LOCK_NAME_MAX_LEN + 2, sun_path_size_changed);
-
memset(&address, 0, sizeof(address));
int print_length = snprintf(&address.sun_path[1],
- MULTI_PROCESS_LOCK_NAME_MAX_LEN + 1,
+ max_len + 1,
"%s", name_.c_str());
if (print_length < 0 ||
- print_length > static_cast<int>(MULTI_PROCESS_LOCK_NAME_MAX_LEN)) {
+ print_length > static_cast<int>(max_len)) {
PLOG(ERROR) << "Couldn't create sun_path - " << name_;
return false;
}