peer->host = template->host;
+ template->host->valid = host->valid;
+
server = template->host->service.len ? &opeer->server
: &template->server;
static ngx_int_t
ngx_http_upstream_zone_init_worker(ngx_cycle_t *cycle)
{
+ time_t now;
+ ngx_msec_t timer;
ngx_uint_t i;
ngx_event_t *event;
ngx_http_upstream_rr_peer_t *peer;
return NGX_OK;
}
+ now = ngx_time();
umcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_upstream_module);
if (umcf == NULL) {
event->log = cycle->log;
event->cancelable = 1;
- ngx_add_timer(event, 1);
+ timer = (peer->host->valid > now)
+ ? (ngx_msec_t) 1000 * (peer->host->valid - now) : 1;
+
+ ngx_add_timer(event, timer);
}
ngx_http_upstream_rr_peers_unlock(peers);
done:
+ host->valid = ctx->valid;
+
ngx_http_upstream_rr_peers_unlock(peers);
while (++i < ctx->naddrs) {
ngx_uint_t worker;
ngx_str_t name;
ngx_str_t service;
+ time_t valid;
ngx_http_upstream_rr_peers_t *peers;
ngx_http_upstream_rr_peer_t *peer;
} ngx_http_upstream_host_t;
ngx_uint_t worker;
ngx_str_t name;
ngx_str_t service;
+ time_t valid;
ngx_stream_upstream_rr_peers_t *peers;
ngx_stream_upstream_rr_peer_t *peer;
} ngx_stream_upstream_host_t;
peer->host = template->host;
+ template->host->valid = host->valid;
+
server = template->host->service.len ? &opeer->server
: &template->server;
static ngx_int_t
ngx_stream_upstream_zone_init_worker(ngx_cycle_t *cycle)
{
+ time_t now;
+ ngx_msec_t timer;
ngx_uint_t i;
ngx_event_t *event;
ngx_stream_upstream_rr_peer_t *peer;
return NGX_OK;
}
+ now = ngx_time();
umcf = ngx_stream_cycle_get_module_main_conf(cycle,
ngx_stream_upstream_module);
event->log = cycle->log;
event->cancelable = 1;
- ngx_add_timer(event, 1);
+ timer = (peer->host->valid > now)
+ ? (ngx_msec_t) 1000 * (peer->host->valid - now) : 1;
+
+ ngx_add_timer(event, timer);
}
ngx_stream_upstream_rr_peers_unlock(peers);
done:
+ host->valid = ctx->valid;
+
ngx_stream_upstream_rr_peers_unlock(peers);
while (++i < ctx->naddrs) {