| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "sandbox/linux/services/thread_helpers.h" | 5 #include "sandbox/linux/services/thread_helpers.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <signal.h> | 9 #include <signal.h> |
| 10 #include <sys/types.h> | 10 #include <sys/types.h> |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 void ThreadHelpers::AssertSingleThreaded() { | 125 void ThreadHelpers::AssertSingleThreaded() { |
| 126 base::ScopedFD task_fd(ProcUtil::OpenProc()); | 126 base::ScopedFD task_fd(ProcUtil::OpenProc()); |
| 127 AssertSingleThreaded(task_fd.get()); | 127 AssertSingleThreaded(task_fd.get()); |
| 128 } | 128 } |
| 129 | 129 |
| 130 // static | 130 // static |
| 131 bool ThreadHelpers::StopThreadAndWatchProcFS(int proc_fd, | 131 bool ThreadHelpers::StopThreadAndWatchProcFS(int proc_fd, |
| 132 base::Thread* thread) { | 132 base::Thread* thread) { |
| 133 DCHECK_LE(0, proc_fd); | 133 DCHECK_LE(0, proc_fd); |
| 134 DCHECK(thread); | 134 DCHECK(thread); |
| 135 const base::PlatformThreadId thread_id = thread->thread_id(); | 135 const base::PlatformThreadId thread_id = thread->GetThreadId(); |
| 136 const std::string thread_id_dir_str = | 136 const std::string thread_id_dir_str = |
| 137 "self/task/" + base::IntToString(thread_id) + "/"; | 137 "self/task/" + base::IntToString(thread_id) + "/"; |
| 138 | 138 |
| 139 // The kernel is at liberty to wake the thread id futex before updating | 139 // The kernel is at liberty to wake the thread id futex before updating |
| 140 // /proc. Following Stop(), the thread is joined, but entries in /proc may | 140 // /proc. Following Stop(), the thread is joined, but entries in /proc may |
| 141 // not have been updated. | 141 // not have been updated. |
| 142 thread->Stop(); | 142 thread->Stop(); |
| 143 | 143 |
| 144 const base::Callback<bool(void)> cb = | 144 const base::Callback<bool(void)> cb = |
| 145 base::Bind(&IsThreadPresentInProcFS, proc_fd, thread_id_dir_str); | 145 base::Bind(&IsThreadPresentInProcFS, proc_fd, thread_id_dir_str); |
| 146 | 146 |
| 147 RunWhileTrue(cb); | 147 RunWhileTrue(cb); |
| 148 | 148 |
| 149 return true; | 149 return true; |
| 150 } | 150 } |
| 151 | 151 |
| 152 // static | 152 // static |
| 153 const char* ThreadHelpers::GetAssertSingleThreadedErrorMessageForTests() { | 153 const char* ThreadHelpers::GetAssertSingleThreadedErrorMessageForTests() { |
| 154 return kAssertSingleThreadedError; | 154 return kAssertSingleThreadedError; |
| 155 } | 155 } |
| 156 | 156 |
| 157 } // namespace sandbox | 157 } // namespace sandbox |
| OLD | NEW |