Mercurial > hg > nginx-vendor-0-6
annotate src/core/ngx_spinlock.c @ 132:91372f004adf NGINX_0_3_13
nginx 0.3.13
*) Feature: the IMAP/POP3 proxy supports STARTTLS and STLS.
*) Bugfix: the IMAP/POP3 proxy did not work with the select, poll, and
/dev/poll methods.
*) Bugfix: in SSI handling.
*) Bugfix: now Solaris sendfilev() is not used to transfer the client
request body to FastCGI-server via the unix domain socket.
*) Bugfix: the "auth_basic" directive did not disable the
authorization; bug appeared in 0.3.11.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 05 Dec 2005 00:00:00 +0300 |
parents | 408f195b3482 |
children | 73e8476f9142 |
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 | |
42 | 11 /* |
12 * TODO: the P4 optimized assembler version with the "pause" operation | |
13 */ | |
14 | |
112 | 15 void |
16 ngx_spinlock(ngx_atomic_t *lock, ngx_uint_t spin) | |
0 | 17 { |
18 | |
19 #if (NGX_HAVE_ATOMIC_OPS) | |
20 | |
21 ngx_uint_t tries; | |
22 | |
23 tries = 0; | |
24 | |
25 for ( ;; ) { | |
26 | |
27 if (*lock) { | |
28 if (ngx_ncpu > 1 && tries++ < spin) { | |
29 continue; | |
30 } | |
31 | |
32 ngx_sched_yield(); | |
33 | |
34 tries = 0; | |
35 | |
36 } else { | |
37 if (ngx_atomic_cmp_set(lock, 0, 1)) { | |
38 return; | |
39 } | |
40 } | |
41 } | |
42 | |
43 #else | |
44 | |
45 #if (NGX_THREADS) | |
46 | |
47 #error ngx_spinlock() or ngx_atomic_cmp_set() are not defined ! | |
48 | |
49 #endif | |
50 | |
51 #endif | |
52 | |
53 } |