Mercurial > hg > nginx
view src/core/ngx_spinlock.c @ 587:284cc140593b release-0.3.15
nginx-0.3.15-RELEASE import
*) Feature: the new 444 code of the "return" directive to close
connection.
*) Feature: the "so_keepalive" directive in IMAP/POP3 proxy.
*) Bugfix: if there are unclosed connection nginx now calls abort()
only on gracefull quit and active "debug_points" directive.
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 07 Dec 2005 14:51:31 +0000 |
parents | 9c2f3ed7a247 |
children | 3f8a2132b93d |
line wrap: on
line source
/* * Copyright (C) Igor Sysoev */ #include <ngx_config.h> #include <ngx_core.h> /* * TODO: the P4 optimized assembler version with the "pause" operation */ void ngx_spinlock(ngx_atomic_t *lock, ngx_uint_t spin) { #if (NGX_HAVE_ATOMIC_OPS) ngx_uint_t tries; tries = 0; for ( ;; ) { if (*lock) { if (ngx_ncpu > 1 && tries++ < spin) { continue; } ngx_sched_yield(); tries = 0; } else { if (ngx_atomic_cmp_set(lock, 0, 1)) { return; } } } #else #if (NGX_THREADS) #error ngx_spinlock() or ngx_atomic_cmp_set() are not defined ! #endif #endif }