Mercurial > hg > nginx-mail
annotate src/core/ngx_spinlock.c @ 96:ca4f70b3ccc6 NGINX_0_2_2
nginx 0.2.2
*) Feature: the "config errmsg" command of the ngx_http_ssi_module.
*) Change: the ngx_http_geo_module variables can be overridden by the
"set" directive.
*) Feature: the "ssl_protocols" and "ssl_prefer_server_ciphers"
directives of the ngx_http_ssl_module and ngx_imap_ssl_module.
*) Bugfix: the ngx_http_autoindex_module did not show correctly the
long file names;
*) Bugfix: the ngx_http_autoindex_module now do not show the files
starting by dot.
*) Bugfix: if the SSL handshake failed then another connection may be
closed too.
Thanks to Rob Mueller.
*) Bugfix: the export versions of MSIE 5.x could not connect via HTTPS.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Fri, 30 Sep 2005 00:00:00 +0400 |
parents | 41ccba1aba45 |
children | 408f195b3482 |
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 | |
0 | 15 void ngx_spinlock(ngx_atomic_t *lock, ngx_uint_t spin) |
16 { | |
17 | |
18 #if (NGX_HAVE_ATOMIC_OPS) | |
19 | |
20 ngx_uint_t tries; | |
21 | |
22 tries = 0; | |
23 | |
24 for ( ;; ) { | |
25 | |
26 if (*lock) { | |
27 if (ngx_ncpu > 1 && tries++ < spin) { | |
28 continue; | |
29 } | |
30 | |
31 ngx_sched_yield(); | |
32 | |
33 tries = 0; | |
34 | |
35 } else { | |
36 if (ngx_atomic_cmp_set(lock, 0, 1)) { | |
37 return; | |
38 } | |
39 } | |
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 } |