comparison src/os/unix/ngx_pthread_thread.c @ 112:408f195b3482 NGINX_0_3_3

nginx 0.3.3 *) Change: the "bl" and "af" parameters of the "listen" directive was renamed to the "backlog" and "accept_filter". *) Feature: the "rcvbuf" and "sndbuf" parameters of the "listen" directive. *) Change: the "$msec" log parameter does not require now the additional the gettimeofday() system call. *) Feature: the -t switch now tests the "listen" directives. *) Bugfix: if the invalid address was specified in the "listen" directive, then after the -HUP signal nginx left an open socket in the CLOSED state. *) Bugfix: the mime type may be incorrectly set to default value for index file with variable in the name; bug appeared in 0.3.0. *) Feature: the "timer_resolution" directive. *) Feature: the millisecond "$upstream_response_time" log parameter. *) Bugfix: a temporary file with client request body now is removed just after the response header was transferred to a client. *) Bugfix: OpenSSL 0.9.6 compatibility. *) Bugfix: the SSL certificate and key file paths could not be relative. *) Bugfix: the "ssl_prefer_server_ciphers" directive did not work in the ngx_imap_ssl_module. *) Bugfix: the "ssl_protocols" directive allowed to specify the single protocol only.
author Igor Sysoev <http://sysoev.ru>
date Wed, 19 Oct 2005 00:00:00 +0400
parents 72eb30262aac
children df17fbafec8f
comparison
equal deleted inserted replaced
111:a175b609c76d 112:408f195b3482
13 13
14 14
15 static pthread_attr_t thr_attr; 15 static pthread_attr_t thr_attr;
16 16
17 17
18 ngx_err_t ngx_create_thread(ngx_tid_t *tid, void* (*func)(void *arg), void *arg, 18 ngx_err_t
19 ngx_log_t *log) 19 ngx_create_thread(ngx_tid_t *tid, ngx_thread_value_t (*func)(void *arg),
20 void *arg, ngx_log_t *log)
20 { 21 {
21 int err; 22 int err;
22 23
23 if (nthreads >= max_threads) { 24 if (nthreads >= max_threads) {
24 ngx_log_error(NGX_LOG_CRIT, log, 0, 25 ngx_log_error(NGX_LOG_CRIT, log, 0,
40 41
41 return err; 42 return err;
42 } 43 }
43 44
44 45
45 ngx_int_t ngx_init_threads(int n, size_t size, ngx_cycle_t *cycle) 46 ngx_int_t
47 ngx_init_threads(int n, size_t size, ngx_cycle_t *cycle)
46 { 48 {
47 int err; 49 int err;
48 50
49 max_threads = n; 51 max_threads = n;
50 52
68 70
69 return NGX_OK; 71 return NGX_OK;
70 } 72 }
71 73
72 74
73 ngx_mutex_t *ngx_mutex_init(ngx_log_t *log, ngx_uint_t flags) 75 ngx_mutex_t *
76 ngx_mutex_init(ngx_log_t *log, ngx_uint_t flags)
74 { 77 {
75 int err; 78 int err;
76 ngx_mutex_t *m; 79 ngx_mutex_t *m;
77 80
78 m = ngx_alloc(sizeof(ngx_mutex_t), log); 81 m = ngx_alloc(sizeof(ngx_mutex_t), log);
92 95
93 return m; 96 return m;
94 } 97 }
95 98
96 99
97 void ngx_mutex_destroy(ngx_mutex_t *m) 100 void
101 ngx_mutex_destroy(ngx_mutex_t *m)
98 { 102 {
99 int err; 103 int err;
100 104
101 err = pthread_mutex_destroy(&m->mutex); 105 err = pthread_mutex_destroy(&m->mutex);
102 106
107 111
108 ngx_free(m); 112 ngx_free(m);
109 } 113 }
110 114
111 115
112 ngx_int_t ngx_mutex_lock(ngx_mutex_t *m) 116 void
117 ngx_mutex_lock(ngx_mutex_t *m)
118 {
119 int err;
120
121 if (!ngx_threaded) {
122 return;
123 }
124
125 ngx_log_debug1(NGX_LOG_DEBUG_MUTEX, m->log, 0, "lock mutex %p", m);
126
127 err = pthread_mutex_lock(&m->mutex);
128
129 if (err != 0) {
130 ngx_log_error(NGX_LOG_ALERT, m->log, err,
131 "pthread_mutex_lock(%p) failed", m);
132 ngx_abort();
133 }
134
135 ngx_log_debug1(NGX_LOG_DEBUG_MUTEX, m->log, 0, "mutex %p is locked", m);
136
137 return;
138 }
139
140
141 ngx_int_t
142 ngx_mutex_trylock(ngx_mutex_t *m)
113 { 143 {
114 int err; 144 int err;
115 145
116 if (!ngx_threaded) { 146 if (!ngx_threaded) {
117 return NGX_OK; 147 return NGX_OK;
118 } 148 }
119 149
120 ngx_log_debug1(NGX_LOG_DEBUG_MUTEX, m->log, 0, "lock mutex %p", m);
121
122 err = pthread_mutex_lock(&m->mutex);
123
124 if (err != 0) {
125 ngx_log_error(NGX_LOG_ALERT, m->log, err,
126 "pthread_mutex_lock(%p) failed", m);
127 return NGX_ERROR;
128 }
129
130 ngx_log_debug1(NGX_LOG_DEBUG_MUTEX, m->log, 0, "mutex %p is locked", m);
131
132 return NGX_OK;
133 }
134
135
136 ngx_int_t ngx_mutex_trylock(ngx_mutex_t *m)
137 {
138 int err;
139
140 if (!ngx_threaded) {
141 return NGX_OK;
142 }
143
144 ngx_log_debug1(NGX_LOG_DEBUG_MUTEX, m->log, 0, "try lock mutex %p", m); 150 ngx_log_debug1(NGX_LOG_DEBUG_MUTEX, m->log, 0, "try lock mutex %p", m);
145 151
146 err = pthread_mutex_trylock(&m->mutex); 152 err = pthread_mutex_trylock(&m->mutex);
147 153
148 if (err == NGX_EBUSY) { 154 if (err == NGX_EBUSY) {
150 } 156 }
151 157
152 if (err != 0) { 158 if (err != 0) {
153 ngx_log_error(NGX_LOG_ALERT, m->log, err, 159 ngx_log_error(NGX_LOG_ALERT, m->log, err,
154 "pthread_mutex_trylock(%p) failed", m); 160 "pthread_mutex_trylock(%p) failed", m);
155 return NGX_ERROR; 161 ngx_abort();
156 } 162 }
157 163
158 ngx_log_debug1(NGX_LOG_DEBUG_MUTEX, m->log, 0, "mutex %p is locked", m); 164 ngx_log_debug1(NGX_LOG_DEBUG_MUTEX, m->log, 0, "mutex %p is locked", m);
159 165
160 return NGX_OK; 166 return NGX_OK;
161 } 167 }
162 168
163 169
164 ngx_int_t ngx_mutex_unlock(ngx_mutex_t *m) 170 void
171 ngx_mutex_unlock(ngx_mutex_t *m)
165 { 172 {
166 int err; 173 int err;
167 174
168 if (!ngx_threaded) { 175 if (!ngx_threaded) {
169 return NGX_OK; 176 return;
170 } 177 }
171 178
172 ngx_log_debug1(NGX_LOG_DEBUG_MUTEX, m->log, 0, "unlock mutex %p", m); 179 ngx_log_debug1(NGX_LOG_DEBUG_MUTEX, m->log, 0, "unlock mutex %p", m);
173 180
174 err = pthread_mutex_unlock(&m->mutex); 181 err = pthread_mutex_unlock(&m->mutex);
175 182
176 if (err != 0) { 183 if (err != 0) {
177 ngx_log_error(NGX_LOG_ALERT, m->log, err, 184 ngx_log_error(NGX_LOG_ALERT, m->log, err,
178 "pthread_mutex_unlock(%p) failed", m); 185 "pthread_mutex_unlock(%p) failed", m);
179 return NGX_ERROR; 186 ngx_abort();
180 } 187 }
181 188
182 ngx_log_debug1(NGX_LOG_DEBUG_MUTEX, m->log, 0, "mutex %p is unlocked", m); 189 ngx_log_debug1(NGX_LOG_DEBUG_MUTEX, m->log, 0, "mutex %p is unlocked", m);
183 190
184 return NGX_OK; 191 return;
185 } 192 }
186 193
187 194
188 ngx_cond_t *ngx_cond_init(ngx_log_t *log) 195 ngx_cond_t *
196 ngx_cond_init(ngx_log_t *log)
189 { 197 {
190 int err; 198 int err;
191 ngx_cond_t *cv; 199 ngx_cond_t *cv;
192 200
193 cv = ngx_alloc(sizeof(ngx_cond_t), log); 201 cv = ngx_alloc(sizeof(ngx_cond_t), log);
207 215
208 return cv; 216 return cv;
209 } 217 }
210 218
211 219
212 void ngx_cond_destroy(ngx_cond_t *cv) 220 void
221 ngx_cond_destroy(ngx_cond_t *cv)
213 { 222 {
214 int err; 223 int err;
215 224
216 err = pthread_cond_destroy(&cv->cond); 225 err = pthread_cond_destroy(&cv->cond);
217 226
222 231
223 ngx_free(cv); 232 ngx_free(cv);
224 } 233 }
225 234
226 235
227 ngx_int_t ngx_cond_wait(ngx_cond_t *cv, ngx_mutex_t *m) 236 ngx_int_t
237 ngx_cond_wait(ngx_cond_t *cv, ngx_mutex_t *m)
228 { 238 {
229 int err; 239 int err;
230 240
231 ngx_log_debug1(NGX_LOG_DEBUG_CORE, cv->log, 0, "cv %p wait", cv); 241 ngx_log_debug1(NGX_LOG_DEBUG_CORE, cv->log, 0, "cv %p wait", cv);
232 242
244 254
245 return NGX_OK; 255 return NGX_OK;
246 } 256 }
247 257
248 258
249 ngx_int_t ngx_cond_signal(ngx_cond_t *cv) 259 ngx_int_t
260 ngx_cond_signal(ngx_cond_t *cv)
250 { 261 {
251 int err; 262 int err;
252 263
253 ngx_log_debug1(NGX_LOG_DEBUG_CORE, cv->log, 0, "cv %p to signal", cv); 264 ngx_log_debug1(NGX_LOG_DEBUG_CORE, cv->log, 0, "cv %p to signal", cv);
254 265