comparison src/http/ngx_http_upstream_round_robin.h @ 6103:79ddb0bdb273

Upstream: the "zone" directive. Upstreams with the "zone" directive are kept in shared memory, with a consistent view of all worker processes.
author Ruslan Ermilov <ru@nginx.com>
date Tue, 14 Apr 2015 19:01:25 +0300
parents 3264b7828f72
children 311d232ad803
comparison
equal deleted inserted replaced
6102:3264b7828f72 6103:79ddb0bdb273
36 time_t fail_timeout; 36 time_t fail_timeout;
37 37
38 ngx_uint_t down; /* unsigned down:1; */ 38 ngx_uint_t down; /* unsigned down:1; */
39 39
40 #if (NGX_HTTP_SSL) 40 #if (NGX_HTTP_SSL)
41 ngx_ssl_session_t *ssl_session; /* local to a process */ 41 void *ssl_session;
42 int ssl_session_len;
42 #endif 43 #endif
43 44
44 ngx_http_upstream_rr_peer_t *next; 45 ngx_http_upstream_rr_peer_t *next;
46
47 #if (NGX_HTTP_UPSTREAM_ZONE)
48 ngx_atomic_t lock;
49 #endif
45 }; 50 };
46 51
47 52
48 typedef struct ngx_http_upstream_rr_peers_s ngx_http_upstream_rr_peers_t; 53 typedef struct ngx_http_upstream_rr_peers_s ngx_http_upstream_rr_peers_t;
49 54
50 struct ngx_http_upstream_rr_peers_s { 55 struct ngx_http_upstream_rr_peers_s {
51 ngx_uint_t number; 56 ngx_uint_t number;
57
58 #if (NGX_HTTP_UPSTREAM_ZONE)
59 ngx_slab_pool_t *shpool;
60 ngx_atomic_t rwlock;
61 #endif
52 62
53 ngx_uint_t total_weight; 63 ngx_uint_t total_weight;
54 64
55 unsigned single:1; 65 unsigned single:1;
56 unsigned weighted:1; 66 unsigned weighted:1;
61 71
62 ngx_http_upstream_rr_peer_t *peer; 72 ngx_http_upstream_rr_peer_t *peer;
63 }; 73 };
64 74
65 75
76 #if (NGX_HTTP_UPSTREAM_ZONE)
77
78 #define ngx_http_upstream_rr_peers_rlock(peers) \
79 \
80 if (peers->shpool) { \
81 ngx_rwlock_rlock(&peers->rwlock); \
82 }
83
84 #define ngx_http_upstream_rr_peers_wlock(peers) \
85 \
86 if (peers->shpool) { \
87 ngx_rwlock_wlock(&peers->rwlock); \
88 }
89
90 #define ngx_http_upstream_rr_peers_unlock(peers) \
91 \
92 if (peers->shpool) { \
93 ngx_rwlock_unlock(&peers->rwlock); \
94 }
95
96
97 #define ngx_http_upstream_rr_peer_lock(peers, peer) \
98 \
99 if (peers->shpool) { \
100 ngx_rwlock_wlock(&peer->lock); \
101 }
102
103 #define ngx_http_upstream_rr_peer_unlock(peers, peer) \
104 \
105 if (peers->shpool) { \
106 ngx_rwlock_unlock(&peer->lock); \
107 }
108
109 #else
110
66 #define ngx_http_upstream_rr_peers_rlock(peers) 111 #define ngx_http_upstream_rr_peers_rlock(peers)
67 #define ngx_http_upstream_rr_peers_wlock(peers) 112 #define ngx_http_upstream_rr_peers_wlock(peers)
68 #define ngx_http_upstream_rr_peers_unlock(peers) 113 #define ngx_http_upstream_rr_peers_unlock(peers)
69 #define ngx_http_upstream_rr_peer_lock(peers, peer) 114 #define ngx_http_upstream_rr_peer_lock(peers, peer)
70 #define ngx_http_upstream_rr_peer_unlock(peers, peer) 115 #define ngx_http_upstream_rr_peer_unlock(peers, peer)
116
117 #endif
71 118
72 119
73 typedef struct { 120 typedef struct {
74 ngx_http_upstream_rr_peers_t *peers; 121 ngx_http_upstream_rr_peers_t *peers;
75 ngx_http_upstream_rr_peer_t *current; 122 ngx_http_upstream_rr_peer_t *current;