[nginx] Resolver: do not enable resolve timer if provided timeout is zero.
Dmitry Volyntsev
xeioex at nginx.com
Wed Mar 23 14:50:20 UTC 2016
details: http://hg.nginx.org/nginx/rev/a6711b85da83
branches:
changeset: 6457:a6711b85da83
user: Dmitry Volyntsev <xeioex at nginx.com>
date: Wed Mar 23 17:44:36 2016 +0300
description:
Resolver: do not enable resolve timer if provided timeout is zero.
diffstat:
src/core/ngx_resolver.c | 48 ++++++++++++++++++++++++++----------------------
1 files changed, 26 insertions(+), 22 deletions(-)
diffs (83 lines):
diff -r c94aba230a5a -r a6711b85da83 src/core/ngx_resolver.c
--- a/src/core/ngx_resolver.c Wed Mar 23 17:44:36 2016 +0300
+++ b/src/core/ngx_resolver.c Wed Mar 23 17:44:36 2016 +0300
@@ -611,7 +611,7 @@ ngx_resolve_name_locked(ngx_resolver_t *
if (rn->waiting) {
- if (ctx->event == NULL) {
+ if (ctx->event == NULL && ctx->timeout) {
ctx->event = ngx_resolver_calloc(r, sizeof(ngx_event_t));
if (ctx->event == NULL) {
return NGX_ERROR;
@@ -729,7 +729,7 @@ ngx_resolve_name_locked(ngx_resolver_t *
goto failed;
}
- if (ctx->event == NULL) {
+ if (ctx->event == NULL && ctx->timeout) {
ctx->event = ngx_resolver_calloc(r, sizeof(ngx_event_t));
if (ctx->event == NULL) {
goto failed;
@@ -872,18 +872,20 @@ ngx_resolve_addr(ngx_resolver_ctx_t *ctx
if (rn->waiting) {
- ctx->event = ngx_resolver_calloc(r, sizeof(ngx_event_t));
- if (ctx->event == NULL) {
- return NGX_ERROR;
+ if (ctx->event == NULL && ctx->timeout) {
+ ctx->event = ngx_resolver_calloc(r, sizeof(ngx_event_t));
+ if (ctx->event == NULL) {
+ return NGX_ERROR;
+ }
+
+ ctx->event->handler = ngx_resolver_timeout_handler;
+ ctx->event->data = ctx;
+ ctx->event->log = r->log;
+ ctx->ident = -1;
+
+ ngx_add_timer(ctx->event, ctx->timeout);
}
- ctx->event->handler = ngx_resolver_timeout_handler;
- ctx->event->data = ctx;
- ctx->event->log = r->log;
- ctx->ident = -1;
-
- ngx_add_timer(ctx->event, ctx->timeout);
-
ctx->next = rn->waiting;
rn->waiting = ctx;
ctx->state = NGX_AGAIN;
@@ -949,18 +951,20 @@ ngx_resolve_addr(ngx_resolver_ctx_t *ctx
goto failed;
}
- ctx->event = ngx_resolver_calloc(r, sizeof(ngx_event_t));
- if (ctx->event == NULL) {
- goto failed;
+ if (ctx->event == NULL && ctx->timeout) {
+ ctx->event = ngx_resolver_calloc(r, sizeof(ngx_event_t));
+ if (ctx->event == NULL) {
+ goto failed;
+ }
+
+ ctx->event->handler = ngx_resolver_timeout_handler;
+ ctx->event->data = ctx;
+ ctx->event->log = r->log;
+ ctx->ident = -1;
+
+ ngx_add_timer(ctx->event, ctx->timeout);
}
- ctx->event->handler = ngx_resolver_timeout_handler;
- ctx->event->data = ctx;
- ctx->event->log = r->log;
- ctx->ident = -1;
-
- ngx_add_timer(ctx->event, ctx->timeout);
-
if (ngx_queue_empty(resend_queue)) {
ngx_add_timer(r->event, (ngx_msec_t) (r->resend_timeout * 1000));
}
More information about the nginx-devel
mailing list