~ubuntu-branches/ubuntu/precise/krb5/precise-updates

« back to all changes in this revision

Viewing changes to src/windows/identity/util/sync.h

  • Committer: Package Import Robot
  • Author(s): Sam Hartman
  • Date: 2011-12-01 19:34:41 UTC
  • mfrom: (28.1.14 sid)
  • Revision ID: package-import@ubuntu.com-20111201193441-9tipg3aru1jsidyv
Tags: 1.10+dfsg~alpha1-6
* Fix segfault with unknown hostnames in krb5_sname_to_principal,
  Closes: #650671
* Indicate that this library breaks libsmbclient versions that depend on
  krb5_locate_kdc, Closes: #650603, #650611

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (c) 2005 Massachusetts Institute of Technology
3
 
 *
4
 
 * Permission is hereby granted, free of charge, to any person
5
 
 * obtaining a copy of this software and associated documentation
6
 
 * files (the "Software"), to deal in the Software without
7
 
 * restriction, including without limitation the rights to use, copy,
8
 
 * modify, merge, publish, distribute, sublicense, and/or sell copies
9
 
 * of the Software, and to permit persons to whom the Software is
10
 
 * furnished to do so, subject to the following conditions:
11
 
 *
12
 
 * The above copyright notice and this permission notice shall be
13
 
 * included in all copies or substantial portions of the Software.
14
 
 *
15
 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
 
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
 
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
 
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19
 
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20
 
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
 
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
 
 * SOFTWARE.
23
 
 */
24
 
 
25
 
/* $Id$ */
26
 
 
27
 
#ifndef __KHIMAIRA_SYNC_H
28
 
#define __KHIMAIRA_SYNC_H
29
 
 
30
 
#include<khdefs.h>
31
 
 
32
 
/*! \addtogroup util
33
 
    @{ */
34
 
 
35
 
/*! \defgroup util_sync Synchronization
36
 
    @{*/
37
 
 
38
 
/*! \brief A read/write lock
39
 
 
40
 
    A classic read/write lock.  Allows multiple readers or a single
41
 
    writer to access a protected object.  Readers will wait for any
42
 
    pending writer to release the lock, while a writer will wait for
43
 
    any pending readers to release the lock.
44
 
*/
45
 
typedef struct tag_rwlock {
46
 
    int locks;
47
 
    int status;
48
 
    CRITICAL_SECTION cs;
49
 
    HANDLE readwx;
50
 
    HANDLE writewx;
51
 
 
52
 
    DWORD writer;               /* TID of writer thread */
53
 
} rw_lock_t;
54
 
 
55
 
typedef rw_lock_t RWLOCK, *PRWLOCK;
56
 
 
57
 
/*! \brief Initialize a read/write lock.
58
 
 
59
 
    A lock <b>must</b> be initialized before it can be used.
60
 
    Initializing the lock does not grant the caller any locks on the
61
 
    object.
62
 
*/
63
 
KHMEXP void KHMAPI InitializeRwLock(PRWLOCK pLock);
64
 
 
65
 
/*! \brief Delete a read/write lock
66
 
 
67
 
    Once the application is done using the read/write lock, it must be
68
 
    deleted with a call to DeleteRwLock()
69
 
*/
70
 
KHMEXP void KHMAPI DeleteRwLock(PRWLOCK pLock);
71
 
 
72
 
/*! \brief Obtains a read lock on the read/write lock
73
 
 
74
 
    Multiple readers can obtain read locks on the same r/w lock.
75
 
    However, if any thread attempts to obtain a write lock on the
76
 
    object, it will wait until all readers have released the read
77
 
    locks.
78
 
 
79
 
    Call LockReleaseRead() to release the read lock.  While the same
80
 
    thread may obtain multiple read locks on the same object, each
81
 
    call to LockObtainRead() must have a corresponding call to
82
 
    LockReleaseRead() to properly relinquish the lock.
83
 
 
84
 
    \see LockReleaseRead()
85
 
*/
86
 
KHMEXP void KHMAPI LockObtainRead(PRWLOCK pLock);
87
 
 
88
 
/*! \brief Relase a read lock obtained on a read/write lock
89
 
 
90
 
    Each call to LockObtainRead() must have a corresponding call to
91
 
    LockReleaseRead().  Once all read locks are released, any threads
92
 
    waiting on write locks on the object will be woken and assigned a
93
 
    write lock.
94
 
 
95
 
    \see LockObtainRead()
96
 
*/
97
 
KHMEXP void KHMAPI LockReleaseRead(PRWLOCK pLock);
98
 
 
99
 
/*! \brief Obtains a write lock on the read/write lock
100
 
 
101
 
    Only a single writer is allowed to lock a single r/w lock.
102
 
    However, if any thread attempts to obtain a read lock on the
103
 
    object, it will wait until the writer has released the lock.
104
 
 
105
 
    Call LockReleaseWrite() to release the write lock.  While the same
106
 
    thread may obtain multiple write locks on the same object, each
107
 
    call to LockObtainWrite() must have a corresponding call to
108
 
    LockReleaseWrite() to properly relinquish the lock.
109
 
 
110
 
    \see LockReleaseWrite()
111
 
*/
112
 
KHMEXP void KHMAPI LockObtainWrite(PRWLOCK pLock);
113
 
 
114
 
/*! \brief Relase a write lock obtained on a read/write lock
115
 
 
116
 
    Each call to LockObtainWrite() must have a corresponding call to
117
 
    LockReleaseWrite().  Once the write lock is released, any threads
118
 
    waiting for read or write locks on the object will be woken and
119
 
    assigned the proper lock.
120
 
 
121
 
    \see LockObtainWrite()
122
 
*/
123
 
KHMEXP void KHMAPI LockReleaseWrite(PRWLOCK pLock);
124
 
 
125
 
/*@}*/
126
 
/*@}*/
127
 
 
128
 
#endif