diff options
| author | Tom Yu <tlyu@mit.edu> | 2011-12-12 20:46:20 +0000 |
|---|---|---|
| committer | Tom Yu <tlyu@mit.edu> | 2011-12-12 20:46:20 +0000 |
| commit | db0db11147deb5767cccb46820401c2754a7ed16 (patch) | |
| tree | 33e3b4cc027b04259070bf3fc4fd860234358d06 /src/ccapi/common | |
| parent | 8c6030f1d6f8531563297d984848b46b9ede86bf (diff) | |
| download | krb5-db0db11147deb5767cccb46820401c2754a7ed16.tar.gz krb5-db0db11147deb5767cccb46820401c2754a7ed16.tar.xz krb5-db0db11147deb5767cccb46820401c2754a7ed16.zip | |
Split cci_thread_init into per-process and per-thread portions
Call the per-thread code on thread attach and per-process once per
process. Previously, while the function was named 'thread', it was
only actually called once per process. Currently, the per-thread
code does nothing on non-windows platforms and is not even actually
invoked.
Fixes a windows bug when multiple non-main threads try to use ccapi
at the same time.
Signed-off-by: Kevin Wasserman <kevin.wasserman@painless-security.com>
ticket: 7050
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25569 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/ccapi/common')
| -rw-r--r-- | src/ccapi/common/win/OldCC/autolock.hxx | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/ccapi/common/win/OldCC/autolock.hxx b/src/ccapi/common/win/OldCC/autolock.hxx index bbd773488..45b881e22 100644 --- a/src/ccapi/common/win/OldCC/autolock.hxx +++ b/src/ccapi/common/win/OldCC/autolock.hxx @@ -35,10 +35,8 @@ public: ~CcOsLock() {DeleteCriticalSection(&cs); valid = false;} void lock() {if (valid) EnterCriticalSection(&cs);} void unlock() {if (valid) LeaveCriticalSection(&cs);} -#if 0 bool trylock() {return valid ? (TryEnterCriticalSection(&cs) ? true : false) : false; } -#endif }; class CcAutoLock { @@ -50,4 +48,13 @@ public: ~CcAutoLock() { m_lock.unlock(); } }; +class CcAutoTryLock { + CcOsLock& m_lock; + bool m_locked; +public: + CcAutoTryLock(CcOsLock& lock):m_lock(lock) { m_locked = m_lock.trylock(); } + ~CcAutoTryLock() { if (m_locked) m_lock.unlock(); m_locked = false; } + bool IsLocked() const { return m_locked; } +}; + #endif /* __AUTOLOCK_HXX */ |
