1
1
local monotime = require " cqueues" .monotime
2
2
local ca = require " cqueues.auxlib"
3
+ local ce = require " cqueues.errno"
3
4
local cs = require " cqueues.socket"
4
5
local cqueues_dns = require " cqueues.dns"
5
6
local cqueues_dns_record = require " cqueues.dns.record"
@@ -192,7 +193,10 @@ local function connect(options, timeout)
192
193
}
193
194
194
195
local lasterr , lasterrno = " The name does not resolve for the supplied parameters"
195
- for _ , rec in ipairs (records ) do
196
+ local i = 1
197
+ local n = # records
198
+ while i <= n do
199
+ local rec = records [i ]
196
200
connect_params .family = rec .family ;
197
201
connect_params .host = rec .host ;
198
202
connect_params .path = rec .path ;
@@ -214,6 +218,21 @@ local function connect(options, timeout)
214
218
end
215
219
timeout = deadline and deadline - monotime ()
216
220
end
221
+ if lasterrno == ce .EAFNOSUPPORT then
222
+ -- If an address family is not supported then entirely remove that
223
+ -- family from candidate records
224
+ local af = connect_params .family
225
+ for j = n , i + 1 , - 1 do
226
+ if records [j ].family == af then
227
+ table.remove (records , j )
228
+ n = n - 1
229
+ end
230
+ end
231
+ table.remove (records , i )
232
+ n = n - 1
233
+ else
234
+ i = i + 1
235
+ end
217
236
end
218
237
return nil , lasterr , lasterrno
219
238
end
0 commit comments