Mercurial > hg > nginx-vendor-1-0
annotate src/core/ngx_spinlock.c @ 282:675a39fd14cd NGINX_0_5_11
nginx 0.5.11
*) Feature: now configure detects system PCRE library in MacPorts.
Thanks to Chris McGrath.
*) Bugfix: the response was incorrect if several ranges were requested;
bug appeared in 0.5.6.
*) Bugfix: the "create_full_put_path" directive could not create the
intermediate directories if no "dav_access" directive was set.
Thanks to Evan Miller.
*) Bugfix: the "0" response code might be logged in the access_log
instead of the "400" and "408" error codes.
*) Bugfix: a segmentation fault might occur in worker process if nginx
was built with -O2 optimization.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 05 Feb 2007 00:00:00 +0300 |
parents | 73e8476f9142 |
children | ad25218fd14b |
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 } |