diff options
| author | Ruslan Ermilov <ru@nginx.com> | 2015-04-14 19:01:25 +0300 |
|---|---|---|
| committer | Ruslan Ermilov <ru@nginx.com> | 2015-04-14 19:01:25 +0300 |
| commit | cf31347ee84fdaa02f768e641d1a2f1352b6a56a (patch) | |
| tree | 95fa2e6267ffddd5d3ace7bf8108964e7c68fed8 /src/http/ngx_http_upstream_round_robin.h | |
| parent | b0b7b5a356c7dedf4a1867e94d8a36cbb6dc3da1 (diff) | |
| download | nginx-cf31347ee84fdaa02f768e641d1a2f1352b6a56a.tar.gz nginx-cf31347ee84fdaa02f768e641d1a2f1352b6a56a.tar.bz2 | |
Upstream: the "zone" directive.
Upstreams with the "zone" directive are kept in shared memory,
with a consistent view of all worker processes.
Diffstat (limited to 'src/http/ngx_http_upstream_round_robin.h')
| -rw-r--r-- | src/http/ngx_http_upstream_round_robin.h | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/src/http/ngx_http_upstream_round_robin.h b/src/http/ngx_http_upstream_round_robin.h index 0dca40e18..454515cdd 100644 --- a/src/http/ngx_http_upstream_round_robin.h +++ b/src/http/ngx_http_upstream_round_robin.h @@ -38,10 +38,15 @@ struct ngx_http_upstream_rr_peer_s { ngx_uint_t down; /* unsigned down:1; */ #if (NGX_HTTP_SSL) - ngx_ssl_session_t *ssl_session; /* local to a process */ + void *ssl_session; + int ssl_session_len; #endif ngx_http_upstream_rr_peer_t *next; + +#if (NGX_HTTP_UPSTREAM_ZONE) + ngx_atomic_t lock; +#endif }; @@ -50,6 +55,11 @@ typedef struct ngx_http_upstream_rr_peers_s ngx_http_upstream_rr_peers_t; struct ngx_http_upstream_rr_peers_s { ngx_uint_t number; +#if (NGX_HTTP_UPSTREAM_ZONE) + ngx_slab_pool_t *shpool; + ngx_atomic_t rwlock; +#endif + ngx_uint_t total_weight; unsigned single:1; @@ -63,12 +73,49 @@ struct ngx_http_upstream_rr_peers_s { }; +#if (NGX_HTTP_UPSTREAM_ZONE) + +#define ngx_http_upstream_rr_peers_rlock(peers) \ + \ + if (peers->shpool) { \ + ngx_rwlock_rlock(&peers->rwlock); \ + } + +#define ngx_http_upstream_rr_peers_wlock(peers) \ + \ + if (peers->shpool) { \ + ngx_rwlock_wlock(&peers->rwlock); \ + } + +#define ngx_http_upstream_rr_peers_unlock(peers) \ + \ + if (peers->shpool) { \ + ngx_rwlock_unlock(&peers->rwlock); \ + } + + +#define ngx_http_upstream_rr_peer_lock(peers, peer) \ + \ + if (peers->shpool) { \ + ngx_rwlock_wlock(&peer->lock); \ + } + +#define ngx_http_upstream_rr_peer_unlock(peers, peer) \ + \ + if (peers->shpool) { \ + ngx_rwlock_unlock(&peer->lock); \ + } + +#else + #define ngx_http_upstream_rr_peers_rlock(peers) #define ngx_http_upstream_rr_peers_wlock(peers) #define ngx_http_upstream_rr_peers_unlock(peers) #define ngx_http_upstream_rr_peer_lock(peers, peer) #define ngx_http_upstream_rr_peer_unlock(peers, peer) +#endif + typedef struct { ngx_http_upstream_rr_peers_t *peers; |
