Mercurial > hg > nginx-quic
comparison src/core/ngx_resolver.c @ 7312:54683f650cbd
Resolver: retry sending queries on errors (ticket #1511).
Errors when sending UDP datagrams can happen, e.g., when local IP address
changes (see fa0e093b64d7), or an unavailable DNS server on the LAN can cause
send() to fail with EHOSTDOWN on BSD systems. If this happens during
initial query, retry sending immediately, to a different DNS server when
possible. If this is not enough, allow normal resend to happen by ignoring
the return code of the second ngx_resolver_send_query() call, much like we
do in ngx_resolver_resend().
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 05 Jul 2018 22:21:14 +0300 |
parents | faf14dc9ab4d |
children | cbc5dee8d5d2 |
comparison
equal
deleted
inserted
replaced
7311:778358452a81 | 7312:54683f650cbd |
---|---|
845 rn->tcp6 = 0; | 845 rn->tcp6 = 0; |
846 #endif | 846 #endif |
847 rn->nsrvs = 0; | 847 rn->nsrvs = 0; |
848 | 848 |
849 if (ngx_resolver_send_query(r, rn) != NGX_OK) { | 849 if (ngx_resolver_send_query(r, rn) != NGX_OK) { |
850 goto failed; | 850 |
851 /* immediately retry once on failure */ | |
852 | |
853 rn->last_connection++; | |
854 if (rn->last_connection == r->connections.nelts) { | |
855 rn->last_connection = 0; | |
856 } | |
857 | |
858 (void) ngx_resolver_send_query(r, rn); | |
851 } | 859 } |
852 | 860 |
853 if (ngx_resolver_set_timeout(r, ctx) != NGX_OK) { | 861 if (ngx_resolver_set_timeout(r, ctx) != NGX_OK) { |
854 goto failed; | 862 goto failed; |
855 } | 863 } |
1049 rn->tcp6 = 0; | 1057 rn->tcp6 = 0; |
1050 #endif | 1058 #endif |
1051 rn->nsrvs = 0; | 1059 rn->nsrvs = 0; |
1052 | 1060 |
1053 if (ngx_resolver_send_query(r, rn) != NGX_OK) { | 1061 if (ngx_resolver_send_query(r, rn) != NGX_OK) { |
1054 goto failed; | 1062 |
1063 /* immediately retry once on failure */ | |
1064 | |
1065 rn->last_connection++; | |
1066 if (rn->last_connection == r->connections.nelts) { | |
1067 rn->last_connection = 0; | |
1068 } | |
1069 | |
1070 (void) ngx_resolver_send_query(r, rn); | |
1055 } | 1071 } |
1056 | 1072 |
1057 if (ngx_resolver_set_timeout(r, ctx) != NGX_OK) { | 1073 if (ngx_resolver_set_timeout(r, ctx) != NGX_OK) { |
1058 goto failed; | 1074 goto failed; |
1059 } | 1075 } |