Why ngx_trylock do extra judgement?

贾凯 jiakai1000 at gmail.com
Sat Jul 19 09:56:43 UTC 2014


Hi there,

function ngx_shmtx_lock:		if (*mtx->lock == 0 && ngx_atomic_cmp_set(mtx->lock, 0, ngx_pid))
and ngx_trylock (ngx_atomic.h):		(*(lock) == 0 && ngx_atomic_cmp_set(lock, 0, 1))

I think ngx_atomic_cmp_set is enough, why Nginx do extra judgement ahead of it ?



More information about the nginx mailing list