This source file includes following definitions.
- mutex_destroyer
- cond_destroyer
- _rf_create_managed_mutex
- _rf_create_managed_cond
- _rf_init_managed_threadgroup
- _rf_destroy_threadgroup
- _rf_init_threadgroup
- rf_mutex_init
- rf_mutex_destroy
- rf_cond_init
- rf_cond_destroy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 #include "rf_types.h"
36 #include "rf_threadstuff.h"
37 #include "rf_general.h"
38 #include "rf_shutdown.h"
39
40 void mutex_destroyer(void *);
41 void cond_destroyer(void *);
42
43
44
45
46
47 void
48 mutex_destroyer(void *arg)
49 {
50 int rc;
51
52 rc = rf_mutex_destroy(arg);
53 if (rc) {
54 RF_ERRORMSG1("RAIDFRAME: Error %d auto-destroying mutex\n", rc);
55 }
56 }
57
58 void
59 cond_destroyer(void *arg)
60 {
61 int rc;
62
63 rc = rf_cond_destroy(arg);
64 if (rc) {
65 RF_ERRORMSG1("RAIDFRAME: Error %d auto-destroying condition\n",
66 rc);
67 }
68 }
69
70 int
71 _rf_create_managed_mutex(RF_ShutdownList_t **listp, RF_DECLARE_MUTEX(*m),
72 char *file, int line)
73 {
74 int rc, rc1;
75
76 rc = rf_mutex_init(m);
77 if (rc)
78 return (rc);
79
80 rc = _rf_ShutdownCreate(listp, mutex_destroyer, (void *) m, file, line);
81 if (rc) {
82 RF_ERRORMSG1("RAIDFRAME: Error %d adding shutdown entry\n", rc);
83 rc1 = rf_mutex_destroy(m);
84 if (rc1) {
85 RF_ERRORMSG1("RAIDFRAME: Error %d destroying mutex\n",
86 rc1);
87 }
88 }
89
90 return (rc);
91 }
92
93 int
94 _rf_create_managed_cond(RF_ShutdownList_t **listp, RF_DECLARE_COND(*c),
95 char *file, int line)
96 {
97 int rc, rc1;
98
99 rc = rf_cond_init(c);
100 if (rc)
101 return (rc);
102
103 rc = _rf_ShutdownCreate(listp, cond_destroyer, (void *) c, file, line);
104 if (rc) {
105 RF_ERRORMSG1("RAIDFRAME: Error %d adding shutdown entry\n", rc);
106 rc1 = rf_cond_destroy(c);
107 if (rc1) {
108 RF_ERRORMSG1("RAIDFRAME: Error %d destroying cond\n",
109 rc1);
110 }
111 }
112 return (rc);
113 }
114
115 int
116 _rf_init_managed_threadgroup(RF_ShutdownList_t **listp, RF_ThreadGroup_t *g,
117 char *file, int line)
118 {
119 int rc;
120
121 rc = _rf_create_managed_mutex(listp, &g->mutex, file, line);
122 if (rc)
123 return (rc);
124
125 rc = _rf_create_managed_cond(listp, &g->cond, file, line);
126 if (rc)
127 return (rc);
128
129 g->created = g->running = g->shutdown = 0;
130 return (0);
131 }
132
133 int
134 _rf_destroy_threadgroup(RF_ThreadGroup_t *g, char *file, int line)
135 {
136 int rc1, rc2;
137
138 rc1 = rf_mutex_destroy(&g->mutex);
139 rc2 = rf_cond_destroy(&g->cond);
140
141 if (rc1)
142 return (rc1);
143
144 return (rc2);
145 }
146
147 int
148 _rf_init_threadgroup(RF_ThreadGroup_t *g, char *file, int line)
149 {
150 int rc;
151
152 rc = rf_mutex_init(&g->mutex);
153 if (rc)
154 return (rc);
155
156 rc = rf_cond_init(&g->cond);
157 if (rc) {
158 rf_mutex_destroy(&g->mutex);
159 return (rc);
160 }
161
162 g->created = g->running = g->shutdown = 0;
163 return (0);
164 }
165
166
167
168
169
170
171 int
172 rf_mutex_init(decl_simple_lock_data(, *m))
173 {
174 simple_lock_init(m);
175 return (0);
176 }
177
178 int
179 rf_mutex_destroy(decl_simple_lock_data(, *m))
180 {
181 return (0);
182 }
183
184 int
185 rf_cond_init(RF_DECLARE_COND(*c))
186 {
187 *c = 0;
188 return (0);
189 }
190
191 int
192 rf_cond_destroy(RF_DECLARE_COND(*c))
193 {
194 return (0);
195 }