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"
@@ -202,7 +203,10 @@ local function connect(options, timeout)
202
203
}
203
204
204
205
local lasterr , lasterrno = " The name does not resolve for the supplied parameters"
205
- for _ , rec in ipairs (records ) do
206
+ local i = 1
207
+ local n = # records
208
+ while i <= n do
209
+ local rec = records [i ]
206
210
connect_params .family = rec .family ;
207
211
connect_params .host = rec .host ;
208
212
connect_params .path = rec .path ;
@@ -224,6 +228,21 @@ local function connect(options, timeout)
224
228
end
225
229
timeout = deadline and deadline - monotime ()
226
230
end
231
+ if lasterrno == ce .EAFNOSUPPORT then
232
+ -- If an address family is not supported then entirely remove that
233
+ -- family from candidate records
234
+ local af = connect_params .family
235
+ for j = n , i + 1 , - 1 do
236
+ if records [j ].family == af then
237
+ table.remove (records , j )
238
+ n = n - 1
239
+ end
240
+ end
241
+ table.remove (records , i )
242
+ n = n - 1
243
+ else
244
+ i = i + 1
245
+ end
227
246
end
228
247
return nil , lasterr , lasterrno
229
248
end
0 commit comments