nginx 的互斥锁nginx 自己实现了互斥锁,这样做的目的主要是为了兼容性,在不支持锁甚至不支持原子操作的环境下实现锁操作 nginx 锁结构ngx_accept_mutex 是一个 ngx_shmtx_t 结构体,ngx_shmtx_t 描述了 nginx 的锁结构// struct ngx_shmtx_t
// nginx 锁结构 {{{
typedef struct {
#if (NGX_HAVE_ATOMIC_OPS) // 是否支持原子操作
ngx_atomic_t *lock;
#if (NGX_HAVE_POSIX_SEM) // 是否支持信号量
ngx_atomic_t *wait;
ngx_uint_t semaphore;
sem_t sem;
#endif
#else // 不支持原子操作则使用文件操作
ngx_fd_t fd;
u_char *name;
#endif
ngx_uint_t spin; // 自旋锁标识
} ngx_shmtx_t; // }}} nginx 使用这个结构实现了&n