src/core/ngx_shmtx.h - nginx-1.7.10

Data types defined

Macros defined

Source code


  1. /*
  2. * Copyright (C) Igor Sysoev
  3. * Copyright (C) Nginx, Inc.
  4. */


  5. #ifndef _NGX_SHMTX_H_INCLUDED_
  6. #define _NGX_SHMTX_H_INCLUDED_


  7. #include <ngx_config.h>
  8. #include <ngx_core.h>


  9. typedef struct {
  10.     ngx_atomic_t   lock;
  11. #if (NGX_HAVE_POSIX_SEM)
  12.     ngx_atomic_t   wait;
  13. #endif
  14. } ngx_shmtx_sh_t;


  15. typedef struct {
  16. #if (NGX_HAVE_ATOMIC_OPS)
  17.     ngx_atomic_t  *lock;
  18. #if (NGX_HAVE_POSIX_SEM)
  19.     ngx_atomic_t  *wait;
  20.     ngx_uint_t     semaphore;
  21.     sem_t          sem;
  22. #endif
  23. #else
  24.     ngx_fd_t       fd;
  25.     u_char        *name;
  26. #endif
  27.     ngx_uint_t     spin;
  28. } ngx_shmtx_t;


  29. ngx_int_t ngx_shmtx_create(ngx_shmtx_t *mtx, ngx_shmtx_sh_t *addr,
  30.     u_char *name);
  31. void ngx_shmtx_destroy(ngx_shmtx_t *mtx);
  32. ngx_uint_t ngx_shmtx_trylock(ngx_shmtx_t *mtx);
  33. void ngx_shmtx_lock(ngx_shmtx_t *mtx);
  34. void ngx_shmtx_unlock(ngx_shmtx_t *mtx);
  35. ngx_uint_t ngx_shmtx_force_unlock(ngx_shmtx_t *mtx, ngx_pid_t pid);


  36. #endif /* _NGX_SHMTX_H_INCLUDED_ */