summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/http/ngx_http_upstream.c13
-rw-r--r--src/http/ngx_http_upstream_round_robin.c26
-rw-r--r--src/http/ngx_http_upstream_round_robin.h4
3 files changed, 36 insertions, 7 deletions
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
index 270e5dac6..88d954f17 100644
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -6535,6 +6535,19 @@ ngx_http_upstream_server(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
continue;
}
+#if (NGX_HTTP_UPSTREAM_STICKY)
+ if (ngx_strcmp(value[i].data, "drain") == 0) {
+
+ if (!(uscf->flags & NGX_HTTP_UPSTREAM_DOWN)) {
+ goto not_supported;
+ }
+
+ us->down = NGX_HTTP_UPSTREAM_DRAINING;
+
+ continue;
+ }
+#endif
+
#if (NGX_HTTP_UPSTREAM_SID)
if (ngx_strncmp(value[i].data, "route=", 6) == 0) {
diff --git a/src/http/ngx_http_upstream_round_robin.c b/src/http/ngx_http_upstream_round_robin.c
index afbb1f23e..412281767 100644
--- a/src/http/ngx_http_upstream_round_robin.c
+++ b/src/http/ngx_http_upstream_round_robin.c
@@ -719,15 +719,23 @@ ngx_http_upstream_get_round_robin_peer(ngx_peer_connection_t *pc, void *data)
#endif
if (peers->single) {
- peer = peers->peer;
+#if (NGX_HTTP_UPSTREAM_SID)
+ peer = ngx_http_upstream_get_rr_peer_by_sid(rrp, pc->hint, &i, 0);
- if (peer->down) {
- goto failed;
- }
+ if (peer == NULL) {
+#endif
+ peer = peers->peer;
- if (peer->max_conns && peer->conns >= peer->max_conns) {
- goto failed;
+ if (peer->down) {
+ goto failed;
+ }
+
+ if (peer->max_conns && peer->conns >= peer->max_conns) {
+ goto failed;
+ }
+#if (NGX_HTTP_UPSTREAM_SID)
}
+#endif
rrp->current = peer;
ngx_http_upstream_rr_peer_ref(peers, peer);
@@ -962,7 +970,11 @@ found:
ngx_http_upstream_rr_peer_lock(rrp->peers, peer);
}
- if (peer->down) {
+ if (peer->down
+#if (NGX_HTTP_UPSTREAM_STICKY)
+ & ~NGX_HTTP_UPSTREAM_DRAINING
+#endif
+ ) {
goto failed;
}
diff --git a/src/http/ngx_http_upstream_round_robin.h b/src/http/ngx_http_upstream_round_robin.h
index 544d0fa20..95c7ae190 100644
--- a/src/http/ngx_http_upstream_round_robin.h
+++ b/src/http/ngx_http_upstream_round_robin.h
@@ -20,6 +20,10 @@
#define NGX_HTTP_UPSTREAM_FAILED 1
+#if (NGX_HTTP_UPSTREAM_STICKY)
+#define NGX_HTTP_UPSTREAM_DRAINING 8
+#endif
+
typedef struct ngx_http_upstream_rr_peers_s ngx_http_upstream_rr_peers_t;
typedef struct ngx_http_upstream_rr_peer_s ngx_http_upstream_rr_peer_t;