Mercurial > hg > nginx
comparison src/os/unix/ngx_pthread_thread.c @ 461:a88a3e4e158f release-0.1.5
nginx-0.1.5-RELEASE import
*) Bugfix: on Solaris and Linux there may be too many "recvmsg()
returned not enough data" alerts.
*) Bugfix: there were the "writev() failed (22: Invalid argument)"
errors on Solaris in proxy mode without sendfile. On other platforms
that do not support sendfile at all the process got caught in an
endless loop.
*) Bugfix: segmentation fault on Solaris in proxy mode and using
sendfile.
*) Bugfix: segmentation fault on Solaris.
*) Bugfix: on-line upgrade did not work on Linux.
*) Bugfix: the ngx_http_autoindex_module module did not escape the
spaces, the quotes, and the percent signs in the directory listing.
*) Change: the decrease of the copy operations.
*) Feature: the userid_p3p directive.
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Thu, 11 Nov 2004 14:07:14 +0000 |
parents | 42d11f017717 |
children | d4ea69372b94 |
comparison
equal
deleted
inserted
replaced
460:5f8319142dfc | 461:a88a3e4e158f |
---|---|
13 | 13 |
14 | 14 |
15 static pthread_attr_t thr_attr; | 15 static pthread_attr_t thr_attr; |
16 | 16 |
17 | 17 |
18 int ngx_create_thread(ngx_tid_t *tid, void* (*func)(void *arg), void *arg, | 18 ngx_err_t ngx_create_thread(ngx_tid_t *tid, void* (*func)(void *arg), void *arg, |
19 ngx_log_t *log) | 19 ngx_log_t *log) |
20 { | 20 { |
21 int err; | 21 int err; |
22 | 22 |
23 if (nthreads >= max_threads) { | 23 if (nthreads >= max_threads) { |
24 ngx_log_error(NGX_LOG_CRIT, log, 0, | 24 ngx_log_error(NGX_LOG_CRIT, log, 0, |
25 "no more than %d threads can be created", max_threads); | 25 "no more than %ui threads can be created", max_threads); |
26 return NGX_ERROR; | 26 return NGX_ERROR; |
27 } | 27 } |
28 | 28 |
29 err = pthread_create(tid, &thr_attr, func, arg); | 29 err = pthread_create(tid, &thr_attr, func, arg); |
30 | 30 |
32 ngx_log_error(NGX_LOG_ALERT, log, err, "pthread_create() failed"); | 32 ngx_log_error(NGX_LOG_ALERT, log, err, "pthread_create() failed"); |
33 return err; | 33 return err; |
34 } | 34 } |
35 | 35 |
36 ngx_log_debug1(NGX_LOG_DEBUG_CORE, log, 0, | 36 ngx_log_debug1(NGX_LOG_DEBUG_CORE, log, 0, |
37 "thread is created: " TID_T_FMT, *tid); | 37 "thread is created: " NGX_TID_T_FMT, *tid); |
38 | 38 |
39 nthreads++; | 39 nthreads++; |
40 | 40 |
41 return err; | 41 return err; |
42 } | 42 } |
68 | 68 |
69 return NGX_OK; | 69 return NGX_OK; |
70 } | 70 } |
71 | 71 |
72 | 72 |
73 ngx_mutex_t *ngx_mutex_init(ngx_log_t *log, uint flags) | 73 ngx_mutex_t *ngx_mutex_init(ngx_log_t *log, ngx_uint_t flags) |
74 { | 74 { |
75 int err; | 75 int err; |
76 ngx_mutex_t *m; | 76 ngx_mutex_t *m; |
77 | 77 |
78 if (!(m = ngx_alloc(sizeof(ngx_mutex_t), log))) { | 78 if (!(m = ngx_alloc(sizeof(ngx_mutex_t), log))) { |
99 | 99 |
100 err = pthread_mutex_destroy(&m->mutex); | 100 err = pthread_mutex_destroy(&m->mutex); |
101 | 101 |
102 if (err != 0) { | 102 if (err != 0) { |
103 ngx_log_error(NGX_LOG_ALERT, m->log, err, | 103 ngx_log_error(NGX_LOG_ALERT, m->log, err, |
104 "pthread_mutex_destroy(" PTR_FMT ") failed", m); | 104 "pthread_mutex_destroy(%p) failed", m); |
105 } | 105 } |
106 | 106 |
107 ngx_free(m); | 107 ngx_free(m); |
108 } | 108 } |
109 | 109 |
114 | 114 |
115 if (!ngx_threaded) { | 115 if (!ngx_threaded) { |
116 return NGX_OK; | 116 return NGX_OK; |
117 } | 117 } |
118 | 118 |
119 ngx_log_debug1(NGX_LOG_DEBUG_MUTEX, m->log, 0, "lock mutex " PTR_FMT, m); | 119 ngx_log_debug1(NGX_LOG_DEBUG_MUTEX, m->log, 0, "lock mutex %p", m); |
120 | 120 |
121 err = pthread_mutex_lock(&m->mutex); | 121 err = pthread_mutex_lock(&m->mutex); |
122 | 122 |
123 if (err != 0) { | 123 if (err != 0) { |
124 ngx_log_error(NGX_LOG_ALERT, m->log, err, | 124 ngx_log_error(NGX_LOG_ALERT, m->log, err, |
125 "pthread_mutex_lock(" PTR_FMT ") failed", m); | 125 "pthread_mutex_lock(%p) failed", m); |
126 return NGX_ERROR; | 126 return NGX_ERROR; |
127 } | 127 } |
128 | 128 |
129 ngx_log_debug1(NGX_LOG_DEBUG_MUTEX, m->log, 0, | 129 ngx_log_debug1(NGX_LOG_DEBUG_MUTEX, m->log, 0, "mutex %p is locked", m); |
130 "mutex " PTR_FMT " is locked", m); | |
131 | 130 |
132 return NGX_OK; | 131 return NGX_OK; |
133 } | 132 } |
134 | 133 |
135 | 134 |
139 | 138 |
140 if (!ngx_threaded) { | 139 if (!ngx_threaded) { |
141 return NGX_OK; | 140 return NGX_OK; |
142 } | 141 } |
143 | 142 |
144 ngx_log_debug1(NGX_LOG_DEBUG_MUTEX, m->log, 0, | 143 ngx_log_debug1(NGX_LOG_DEBUG_MUTEX, m->log, 0, "try lock mutex %p", m); |
145 "try lock mutex " PTR_FMT, m); | |
146 | 144 |
147 err = pthread_mutex_trylock(&m->mutex); | 145 err = pthread_mutex_trylock(&m->mutex); |
148 | 146 |
149 if (err == NGX_EBUSY) { | 147 if (err == NGX_EBUSY) { |
150 return NGX_AGAIN; | 148 return NGX_AGAIN; |
151 } | 149 } |
152 | 150 |
153 if (err != 0) { | 151 if (err != 0) { |
154 ngx_log_error(NGX_LOG_ALERT, m->log, err, | 152 ngx_log_error(NGX_LOG_ALERT, m->log, err, |
155 "pthread_mutex_trylock(" PTR_FMT ") failed", m); | 153 "pthread_mutex_trylock(%p) failed", m); |
156 return NGX_ERROR; | 154 return NGX_ERROR; |
157 } | 155 } |
158 | 156 |
159 ngx_log_debug1(NGX_LOG_DEBUG_MUTEX, m->log, 0, | 157 ngx_log_debug1(NGX_LOG_DEBUG_MUTEX, m->log, 0, "mutex %p is locked", m); |
160 "mutex " PTR_FMT " is locked", m); | |
161 | 158 |
162 return NGX_OK; | 159 return NGX_OK; |
163 } | 160 } |
164 | 161 |
165 | 162 |
169 | 166 |
170 if (!ngx_threaded) { | 167 if (!ngx_threaded) { |
171 return NGX_OK; | 168 return NGX_OK; |
172 } | 169 } |
173 | 170 |
174 ngx_log_debug1(NGX_LOG_DEBUG_MUTEX, m->log, 0, "unlock mutex " PTR_FMT, m); | 171 ngx_log_debug1(NGX_LOG_DEBUG_MUTEX, m->log, 0, "unlock mutex %p", m); |
175 | 172 |
176 err = pthread_mutex_unlock(&m->mutex); | 173 err = pthread_mutex_unlock(&m->mutex); |
177 | 174 |
178 if (err != 0) { | 175 if (err != 0) { |
179 ngx_log_error(NGX_LOG_ALERT, m->log, err, | 176 ngx_log_error(NGX_LOG_ALERT, m->log, err, |
180 "pthread_mutex_unlock(" PTR_FMT ") failed", m); | 177 "pthread_mutex_unlock(%p) failed", m); |
181 return NGX_ERROR; | 178 return NGX_ERROR; |
182 } | 179 } |
183 | 180 |
184 ngx_log_debug1(NGX_LOG_DEBUG_MUTEX, m->log, 0, | 181 ngx_log_debug1(NGX_LOG_DEBUG_MUTEX, m->log, 0, "mutex %p is unlocked", m); |
185 "mutex " PTR_FMT " is unlocked", m); | |
186 | 182 |
187 return NGX_OK; | 183 return NGX_OK; |
188 } | 184 } |
189 | 185 |
190 | 186 |
217 | 213 |
218 err = pthread_cond_destroy(&cv->cond); | 214 err = pthread_cond_destroy(&cv->cond); |
219 | 215 |
220 if (err != 0) { | 216 if (err != 0) { |
221 ngx_log_error(NGX_LOG_ALERT, cv->log, err, | 217 ngx_log_error(NGX_LOG_ALERT, cv->log, err, |
222 "pthread_cond_destroy(" PTR_FMT ") failed", cv); | 218 "pthread_cond_destroy(%p) failed", cv); |
223 } | 219 } |
224 | 220 |
225 ngx_free(cv); | 221 ngx_free(cv); |
226 } | 222 } |
227 | 223 |
228 | 224 |
229 ngx_int_t ngx_cond_wait(ngx_cond_t *cv, ngx_mutex_t *m) | 225 ngx_int_t ngx_cond_wait(ngx_cond_t *cv, ngx_mutex_t *m) |
230 { | 226 { |
231 int err; | 227 int err; |
232 | 228 |
233 ngx_log_debug1(NGX_LOG_DEBUG_CORE, cv->log, 0, | 229 ngx_log_debug1(NGX_LOG_DEBUG_CORE, cv->log, 0, "cv %p wait", cv); |
234 "cv " PTR_FMT " wait", cv); | |
235 | 230 |
236 err = pthread_cond_wait(&cv->cond, &m->mutex); | 231 err = pthread_cond_wait(&cv->cond, &m->mutex); |
237 | 232 |
238 if (err != 0) { | 233 if (err != 0) { |
239 ngx_log_error(NGX_LOG_ALERT, cv->log, err, | 234 ngx_log_error(NGX_LOG_ALERT, cv->log, err, |
240 "pthread_cond_wait(" PTR_FMT ") failed", cv); | 235 "pthread_cond_wait(%p) failed", cv); |
241 return NGX_ERROR; | 236 return NGX_ERROR; |
242 } | 237 } |
243 | 238 |
244 ngx_log_debug1(NGX_LOG_DEBUG_CORE, cv->log, 0, | 239 ngx_log_debug1(NGX_LOG_DEBUG_CORE, cv->log, 0, "cv %p is waked up", cv); |
245 "cv " PTR_FMT " is waked up", cv); | 240 |
246 | 241 ngx_log_debug1(NGX_LOG_DEBUG_MUTEX, m->log, 0, "mutex %p is locked", m); |
247 ngx_log_debug1(NGX_LOG_DEBUG_MUTEX, m->log, 0, | |
248 "mutex " PTR_FMT " is locked", m); | |
249 | 242 |
250 return NGX_OK; | 243 return NGX_OK; |
251 } | 244 } |
252 | 245 |
253 | 246 |
254 ngx_int_t ngx_cond_signal(ngx_cond_t *cv) | 247 ngx_int_t ngx_cond_signal(ngx_cond_t *cv) |
255 { | 248 { |
256 int err; | 249 int err; |
257 | 250 |
258 ngx_log_debug1(NGX_LOG_DEBUG_CORE, cv->log, 0, | 251 ngx_log_debug1(NGX_LOG_DEBUG_CORE, cv->log, 0, "cv %p to signal", cv); |
259 "cv " PTR_FMT " to signal", cv); | |
260 | 252 |
261 err = pthread_cond_signal(&cv->cond); | 253 err = pthread_cond_signal(&cv->cond); |
262 | 254 |
263 if (err != 0) { | 255 if (err != 0) { |
264 ngx_log_error(NGX_LOG_ALERT, cv->log, err, | 256 ngx_log_error(NGX_LOG_ALERT, cv->log, err, |
265 "pthread_cond_signal(" PTR_FMT ") failed", cv); | 257 "pthread_cond_signal(%p) failed", cv); |
266 return NGX_ERROR; | 258 return NGX_ERROR; |
267 } | 259 } |
268 | 260 |
269 ngx_log_debug1(NGX_LOG_DEBUG_CORE, cv->log, 0, | 261 ngx_log_debug1(NGX_LOG_DEBUG_CORE, cv->log, 0, "cv %p is signaled", cv); |
270 "cv " PTR_FMT " is signaled", cv); | 262 |
271 | 263 return NGX_OK; |
272 return NGX_OK; | 264 } |
273 } |