Mercurial > hg > nginx-vendor-0-5
annotate src/core/ngx_spinlock.c @ 210:14050d2bec9b NGINX_0_3_52
nginx 0.3.52
*) Change: the ngx_http_index_module behavior for the "POST /" requests
is reverted to the 0.3.40 version state: the module now does not
return the 405 error.
*) Bugfix: the worker process may got caught in an endless loop if the
limit rate was used; bug appeared in 0.3.37.
*) Bugfix: ngx_http_charset_module logged "unknown charset" alert, even
if the recoding was not needed; bug appeared in 0.3.50.
*) Bugfix: if a code response of the PUT request was 409, then a
temporary file was not removed.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 03 Jul 2006 00:00:00 +0400 |
parents | 73e8476f9142 |
children |
rev | line source |
---|---|
0 | 1 |
2 /* | |
3 * Copyright (C) Igor Sysoev | |
4 */ | |
5 | |
6 | |
7 #include <ngx_config.h> | |
8 #include <ngx_core.h> | |
9 | |
10 | |
112 | 11 void |
160 | 12 ngx_spinlock(ngx_atomic_t *lock, ngx_atomic_int_t value, ngx_uint_t spin) |
0 | 13 { |
14 | |
15 #if (NGX_HAVE_ATOMIC_OPS) | |
16 | |
160 | 17 ngx_uint_t i, n; |
0 | 18 |
19 for ( ;; ) { | |
20 | |
160 | 21 if (*lock == 0 && ngx_atomic_cmp_set(lock, 0, value)) { |
22 return; | |
23 } | |
24 | |
25 if (ngx_ncpu > 1) { | |
26 | |
27 for (n = 1; n < spin; n <<= 1) { | |
0 | 28 |
160 | 29 for (i = 0; i < n; i++) { |
30 ngx_cpu_pause(); | |
31 } | |
0 | 32 |
160 | 33 if (*lock == 0 && ngx_atomic_cmp_set(lock, 0, value)) { |
34 return; | |
35 } | |
0 | 36 } |
37 } | |
160 | 38 |
39 ngx_sched_yield(); | |
0 | 40 } |
41 | |
42 #else | |
43 | |
44 #if (NGX_THREADS) | |
45 | |
46 #error ngx_spinlock() or ngx_atomic_cmp_set() are not defined ! | |
47 | |
48 #endif | |
49 | |
50 #endif | |
51 | |
52 } |