diff --git a/lock.c b/lock.c index 4e8e4cb0..26f744ee 100644 --- a/lock.c +++ b/lock.c @@ -34,6 +34,25 @@ void uwsgi_unlock(void *lock) { } +#endif + +#ifdef UWSGI_LOCK_USE_UMTX + +#include +#include + +void uwsgi_lock_init(void *lock) { + umtx_init((struct umtx*) lock); +} + +void uwsgi_lock(void *lock) { + umtx_lock(lock, 1); +} + +void uwsgi_unlock(void *lock) { + umtx_unlock(lock, 1); +} + #endif diff --git a/uwsgiconfig.py b/uwsgiconfig.py index 9ff44046..8b7bf8a7 100644 --- a/uwsgiconfig.py +++ b/uwsgiconfig.py @@ -195,11 +195,15 @@ class uConf(): if locking_mode == 'auto': if uwsgi_os == 'Linux': locking_mode = 'pthread_mutex' + elif uwsgi_os == 'FreeBSD': + locking_mode = 'umtx' elif uwsgi_os == 'Darwin': locking_mode = 'osx_spinlock' if locking_mode == 'pthread_mutex': self.cflags.append('-DUWSGI_LOCK_USE_MUTEX') + elif locking_mode == 'umtx': + self.cflags.append('-DUWSGI_LOCK_USE_UMTX') elif locking_mode == 'osx_spinlock': self.cflags.append('-DUWSGI_LOCK_USE_OSX_SPINLOCK') else: