2006-02-08 23:33:12 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) Igor Sysoev
|
2012-01-18 23:07:43 +08:00
|
|
|
* Copyright (C) Nginx, Inc.
|
2006-02-08 23:33:12 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _NGX_SHMTX_H_INCLUDED_
|
|
|
|
#define _NGX_SHMTX_H_INCLUDED_
|
|
|
|
|
|
|
|
|
|
|
|
#include <ngx_config.h>
|
|
|
|
#include <ngx_core.h>
|
|
|
|
|
|
|
|
|
2011-11-23 21:55:38 +08:00
|
|
|
typedef struct {
|
|
|
|
ngx_atomic_t lock;
|
|
|
|
#if (NGX_HAVE_POSIX_SEM)
|
|
|
|
ngx_atomic_t wait;
|
|
|
|
#endif
|
|
|
|
} ngx_shmtx_sh_t;
|
|
|
|
|
|
|
|
|
2006-02-08 23:33:12 +08:00
|
|
|
typedef struct {
|
|
|
|
#if (NGX_HAVE_ATOMIC_OPS)
|
|
|
|
ngx_atomic_t *lock;
|
2011-05-10 19:39:13 +08:00
|
|
|
#if (NGX_HAVE_POSIX_SEM)
|
2011-11-23 21:55:38 +08:00
|
|
|
ngx_atomic_t *wait;
|
2011-05-10 19:39:13 +08:00
|
|
|
ngx_uint_t semaphore;
|
|
|
|
sem_t sem;
|
|
|
|
#endif
|
2006-02-08 23:33:12 +08:00
|
|
|
#else
|
|
|
|
ngx_fd_t fd;
|
|
|
|
u_char *name;
|
|
|
|
#endif
|
2011-05-10 19:39:13 +08:00
|
|
|
ngx_uint_t spin;
|
2006-02-08 23:33:12 +08:00
|
|
|
} ngx_shmtx_t;
|
|
|
|
|
|
|
|
|
2011-11-23 21:55:38 +08:00
|
|
|
ngx_int_t ngx_shmtx_create(ngx_shmtx_t *mtx, ngx_shmtx_sh_t *addr,
|
|
|
|
u_char *name);
|
2012-07-03 21:06:40 +08:00
|
|
|
void ngx_shmtx_destroy(ngx_shmtx_t *mtx);
|
2011-05-10 19:39:13 +08:00
|
|
|
ngx_uint_t ngx_shmtx_trylock(ngx_shmtx_t *mtx);
|
|
|
|
void ngx_shmtx_lock(ngx_shmtx_t *mtx);
|
|
|
|
void ngx_shmtx_unlock(ngx_shmtx_t *mtx);
|
2011-11-23 21:55:38 +08:00
|
|
|
ngx_uint_t ngx_shmtx_force_unlock(ngx_shmtx_t *mtx, ngx_pid_t pid);
|
2006-02-08 23:33:12 +08:00
|
|
|
|
|
|
|
|
|
|
|
#endif /* _NGX_SHMTX_H_INCLUDED_ */
|