Mercurial > hg > nginx-quic
annotate src/stream/ngx_stream_upstream_round_robin.h @ 7444:4089b3d2cb59
Win32: added WSAPoll() support.
WSAPoll() is only available with Windows Vista and newer (and only
available during compilation if _WIN32_WINNT >= 0x0600). To make
sure the code works with Windows XP, we do not redefine _WIN32_WINNT,
but instead load WSAPoll() dynamically if it is not available during
compilation.
Also, sockets are not guaranteed to be small integers on Windows.
So an index array is used instead of NGX_USE_FD_EVENT to map
events to connections.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 24 Jan 2019 21:51:21 +0300 |
parents | f41c2530dd17 |
children | 90cc7194e993 |
rev | line source |
---|---|
6115 | 1 |
2 /* | |
3 * Copyright (C) Igor Sysoev | |
4 * Copyright (C) Nginx, Inc. | |
5 */ | |
6 | |
7 | |
8 #ifndef _NGX_STREAM_UPSTREAM_ROUND_ROBIN_H_INCLUDED_ | |
9 #define _NGX_STREAM_UPSTREAM_ROUND_ROBIN_H_INCLUDED_ | |
10 | |
11 | |
12 #include <ngx_config.h> | |
13 #include <ngx_core.h> | |
14 #include <ngx_stream.h> | |
15 | |
16 | |
17 typedef struct ngx_stream_upstream_rr_peer_s ngx_stream_upstream_rr_peer_t; | |
18 | |
19 struct ngx_stream_upstream_rr_peer_s { | |
20 struct sockaddr *sockaddr; | |
21 socklen_t socklen; | |
22 ngx_str_t name; | |
23 ngx_str_t server; | |
24 | |
25 ngx_int_t current_weight; | |
26 ngx_int_t effective_weight; | |
27 ngx_int_t weight; | |
28 | |
29 ngx_uint_t conns; | |
6705 | 30 ngx_uint_t max_conns; |
6115 | 31 |
32 ngx_uint_t fails; | |
33 time_t accessed; | |
34 time_t checked; | |
35 | |
36 ngx_uint_t max_fails; | |
37 time_t fail_timeout; | |
6708
4080f94a996f
Modules compatibility: slow start fields.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6705
diff
changeset
|
38 ngx_msec_t slow_start; |
4080f94a996f
Modules compatibility: slow start fields.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6705
diff
changeset
|
39 ngx_msec_t start_time; |
6115 | 40 |
6713
63b8b157b776
Modules compatibility: down flag promoted to a bitmask.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6712
diff
changeset
|
41 ngx_uint_t down; |
6115 | 42 |
43 void *ssl_session; | |
44 int ssl_session_len; | |
45 | |
46 #if (NGX_STREAM_UPSTREAM_ZONE) | |
47 ngx_atomic_t lock; | |
48 #endif | |
6701
d69964eb8335
Upstream: style, ngx_http_upstream_rr_peer_t.next moved.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6643
diff
changeset
|
49 |
d69964eb8335
Upstream: style, ngx_http_upstream_rr_peer_t.next moved.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6643
diff
changeset
|
50 ngx_stream_upstream_rr_peer_t *next; |
6715
d200a0fd00b7
Introduced the NGX_COMPAT macro.
Ruslan Ermilov <ru@nginx.com>
parents:
6713
diff
changeset
|
51 |
d200a0fd00b7
Introduced the NGX_COMPAT macro.
Ruslan Ermilov <ru@nginx.com>
parents:
6713
diff
changeset
|
52 NGX_COMPAT_BEGIN(25) |
d200a0fd00b7
Introduced the NGX_COMPAT macro.
Ruslan Ermilov <ru@nginx.com>
parents:
6713
diff
changeset
|
53 NGX_COMPAT_END |
6115 | 54 }; |
55 | |
56 | |
57 typedef struct ngx_stream_upstream_rr_peers_s ngx_stream_upstream_rr_peers_t; | |
58 | |
59 struct ngx_stream_upstream_rr_peers_s { | |
60 ngx_uint_t number; | |
61 | |
62 #if (NGX_STREAM_UPSTREAM_ZONE) | |
63 ngx_slab_pool_t *shpool; | |
64 ngx_atomic_t rwlock; | |
6198
311d232ad803
Upstream: fixed shared upstreams on win32.
Ruslan Ermilov <ru@nginx.com>
parents:
6115
diff
changeset
|
65 ngx_stream_upstream_rr_peers_t *zone_next; |
6115 | 66 #endif |
67 | |
68 ngx_uint_t total_weight; | |
69 | |
70 unsigned single:1; | |
71 unsigned weighted:1; | |
72 | |
73 ngx_str_t *name; | |
74 | |
75 ngx_stream_upstream_rr_peers_t *next; | |
76 | |
77 ngx_stream_upstream_rr_peer_t *peer; | |
78 }; | |
79 | |
80 | |
81 #if (NGX_STREAM_UPSTREAM_ZONE) | |
82 | |
83 #define ngx_stream_upstream_rr_peers_rlock(peers) \ | |
84 \ | |
85 if (peers->shpool) { \ | |
86 ngx_rwlock_rlock(&peers->rwlock); \ | |
87 } | |
88 | |
89 #define ngx_stream_upstream_rr_peers_wlock(peers) \ | |
90 \ | |
91 if (peers->shpool) { \ | |
92 ngx_rwlock_wlock(&peers->rwlock); \ | |
93 } | |
94 | |
95 #define ngx_stream_upstream_rr_peers_unlock(peers) \ | |
96 \ | |
97 if (peers->shpool) { \ | |
98 ngx_rwlock_unlock(&peers->rwlock); \ | |
99 } | |
100 | |
101 | |
102 #define ngx_stream_upstream_rr_peer_lock(peers, peer) \ | |
103 \ | |
104 if (peers->shpool) { \ | |
105 ngx_rwlock_wlock(&peer->lock); \ | |
106 } | |
107 | |
108 #define ngx_stream_upstream_rr_peer_unlock(peers, peer) \ | |
109 \ | |
110 if (peers->shpool) { \ | |
111 ngx_rwlock_unlock(&peer->lock); \ | |
112 } | |
113 | |
114 #else | |
115 | |
116 #define ngx_stream_upstream_rr_peers_rlock(peers) | |
117 #define ngx_stream_upstream_rr_peers_wlock(peers) | |
118 #define ngx_stream_upstream_rr_peers_unlock(peers) | |
119 #define ngx_stream_upstream_rr_peer_lock(peers, peer) | |
120 #define ngx_stream_upstream_rr_peer_unlock(peers, peer) | |
121 | |
122 #endif | |
123 | |
124 | |
125 typedef struct { | |
6712
fd5c2781460b
Modules compatibility: upstream config field.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6708
diff
changeset
|
126 ngx_uint_t config; |
6115 | 127 ngx_stream_upstream_rr_peers_t *peers; |
128 ngx_stream_upstream_rr_peer_t *current; | |
129 uintptr_t *tried; | |
130 uintptr_t data; | |
131 } ngx_stream_upstream_rr_peer_data_t; | |
132 | |
133 | |
134 ngx_int_t ngx_stream_upstream_init_round_robin(ngx_conf_t *cf, | |
135 ngx_stream_upstream_srv_conf_t *us); | |
136 ngx_int_t ngx_stream_upstream_init_round_robin_peer(ngx_stream_session_t *s, | |
137 ngx_stream_upstream_srv_conf_t *us); | |
6643
9757cffc1e2f
Stream: variables in proxy_pass and proxy_ssl_name.
Vladimir Homutov <vl@nginx.com>
parents:
6198
diff
changeset
|
138 ngx_int_t ngx_stream_upstream_create_round_robin_peer(ngx_stream_session_t *s, |
9757cffc1e2f
Stream: variables in proxy_pass and proxy_ssl_name.
Vladimir Homutov <vl@nginx.com>
parents:
6198
diff
changeset
|
139 ngx_stream_upstream_resolved_t *ur); |
6115 | 140 ngx_int_t ngx_stream_upstream_get_round_robin_peer(ngx_peer_connection_t *pc, |
141 void *data); | |
142 void ngx_stream_upstream_free_round_robin_peer(ngx_peer_connection_t *pc, | |
143 void *data, ngx_uint_t state); | |
144 | |
145 | |
146 #endif /* _NGX_STREAM_UPSTREAM_ROUND_ROBIN_H_INCLUDED_ */ |