aboutsummaryrefslogtreecommitdiff
path: root/src/client/windows/common
diff options
context:
space:
mode:
authormark@chromium.org <mark@chromium.org@4c0a9323-5329-0410-9bdc-e9ce6186880e>2012-06-12 21:06:11 +0000
committermark@chromium.org <mark@chromium.org@4c0a9323-5329-0410-9bdc-e9ce6186880e>2012-06-12 21:06:11 +0000
commitc50346b3413cd4f5eede6730dd74f950e9968169 (patch)
tree1940501e3d7abe28f7d7058be3c7029dc97969fb /src/client/windows/common
parent Fix uploader so that it send the guid to the server. (diff)
downloadbreakpad-c50346b3413cd4f5eede6730dd74f950e9968169.tar.xz
CrashGenerationServer's state machine can be invoked from both the application
thread and thread pool threads. This CL serializes access to the FSM state. Handling of crash dump and client shutdown requests is still done asynchronously. Patch by Alex Pakhunov <alexeypa@chromium.org> BUG=132164 TEST=remoting_unittests.BreakpadWinDeathTest.* Review URL: https://breakpad.appspot.com/396002/ git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@970 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/client/windows/common')
-rw-r--r--src/client/windows/common/auto_critical_section.h22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/client/windows/common/auto_critical_section.h b/src/client/windows/common/auto_critical_section.h
index 82c7b7f1..a2076b04 100644
--- a/src/client/windows/common/auto_critical_section.h
+++ b/src/client/windows/common/auto_critical_section.h
@@ -40,14 +40,31 @@ class AutoCriticalSection {
public:
// Creates a new instance with the given critical section object
// and enters the critical section immediately.
- explicit AutoCriticalSection(CRITICAL_SECTION* cs) : cs_(cs) {
+ explicit AutoCriticalSection(CRITICAL_SECTION* cs) : cs_(cs), taken_(false) {
assert(cs_);
- EnterCriticalSection(cs_);
+ Acquire();
}
// Destructor: leaves the critical section.
~AutoCriticalSection() {
+ if (taken_) {
+ Release();
+ }
+ }
+
+ // Enters the critical section. Recursive Acquire() calls are not allowed.
+ void Acquire() {
+ assert(!taken_);
+ EnterCriticalSection(cs_);
+ taken_ = true;
+ }
+
+ // Leaves the critical section. The caller should not call Release() unless
+ // the critical seciton has been entered already.
+ void Release() {
+ assert(taken_);
LeaveCriticalSection(cs_);
+ taken_ = false;
}
private:
@@ -56,6 +73,7 @@ class AutoCriticalSection {
AutoCriticalSection& operator=(const AutoCriticalSection&);
CRITICAL_SECTION* cs_;
+ bool taken_;
};
} // namespace google_breakpad