summaryrefslogtreecommitdiffstats
path: root/sandbox/linux/services/thread_helpers.h
diff options
context:
space:
mode:
authorjln <jln@chromium.org>2015-02-09 15:34:17 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-09 23:34:54 +0000
commit7b02f56d77aa785784f117c2c71e56987d80a57b (patch)
treedde4e453e4372d047ea4b0614bf6b121181871d6 /sandbox/linux/services/thread_helpers.h
parent5e62781dabadaf144659e957932ec1f32fe3b078 (diff)
downloadchromium_src-7b02f56d77aa785784f117c2c71e56987d80a57b.zip
chromium_src-7b02f56d77aa785784f117c2c71e56987d80a57b.tar.gz
chromium_src-7b02f56d77aa785784f117c2c71e56987d80a57b.tar.bz2
Linux sandbox: Provide AssertSingleThreaded() helper
Provide a new helper API to assert being single threaded that can wait on the kernel to update /proc/self/task/ Use the helper when started the seccomp sandbox single threaded. BUG=455407 Review URL: https://codereview.chromium.org/893993004 Cr-Commit-Position: refs/heads/master@{#315435}
Diffstat (limited to 'sandbox/linux/services/thread_helpers.h')
-rw-r--r--sandbox/linux/services/thread_helpers.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/sandbox/linux/services/thread_helpers.h b/sandbox/linux/services/thread_helpers.h
index 377742a..88360af 100644
--- a/sandbox/linux/services/thread_helpers.h
+++ b/sandbox/linux/services/thread_helpers.h
@@ -21,12 +21,22 @@ class SANDBOX_EXPORT ThreadHelpers {
// crash if it cannot.
static bool IsSingleThreaded(int proc_self_task);
+ // Crash if the current process is not single threaded. This will wait
+ // on /proc to be updated. In the case where this doesn't crash, this will
+ // return promptly. In the case where this does crash, this will first wait
+ // for a few ms in Debug mode, a few seconds in Release mode.
+ // If |proc_self_tasks| is -1, this method will open /proc/self/task/ and
+ // crash if it cannot.
+ static void AssertSingleThreaded(int proc_self_task);
+
// Stop |thread| and ensure that it does not have an entry in
// /proc/self/task/ from the point of view of the current thread. This is
// the way to stop threads before calling IsSingleThreaded().
- static bool StopThreadAndWatchProcFS(int proc_self_tasks,
+ static bool StopThreadAndWatchProcFS(int proc_self_task,
base::Thread* thread);
+ static const char* GetAssertSingleThreadedErrorMessageForTests();
+
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(ThreadHelpers);
};