@@ -173,10 +173,13 @@ local function connect(options, timeout)
173
173
174
174
local host = options .host
175
175
local records
176
+ local n_records
176
177
if path then
177
178
records = { { family = family , path = path } }
179
+ n_records = 1
178
180
elseif http_util .is_ip (host ) then
179
181
records = { { family = family , host = host } }
182
+ n_records = 1
180
183
else
181
184
local dns_resolver = options .dns_resolver or cqueues_dns .getpool ()
182
185
records = {}
@@ -188,6 +191,7 @@ local function connect(options, timeout)
188
191
elseif family == cs .AF_INET6 then
189
192
dns_lookup (records , dns_resolver , host , cqueues_dns_record .AAAA , cqueues_dns_record .AAAA , timeout )
190
193
end
194
+ n_records = # records
191
195
timeout = deadline and deadline - monotime ()
192
196
end
193
197
@@ -204,8 +208,7 @@ local function connect(options, timeout)
204
208
205
209
local lasterr , lasterrno = " The name does not resolve for the supplied parameters"
206
210
local i = 1
207
- local n = # records
208
- while i <= n do
211
+ while i <= n_records do
209
212
local rec = records [i ]
210
213
connect_params .family = rec .family ;
211
214
connect_params .host = rec .host ;
@@ -232,14 +235,14 @@ local function connect(options, timeout)
232
235
-- If an address family is not supported then entirely remove that
233
236
-- family from candidate records
234
237
local af = connect_params .family
235
- for j = n , i + 1 , - 1 do
238
+ for j = n_records , i + 1 , - 1 do
236
239
if records [j ].family == af then
237
240
table.remove (records , j )
238
- n = n - 1
241
+ n_records = n_records - 1
239
242
end
240
243
end
241
244
table.remove (records , i )
242
- n = n - 1
245
+ n_records = n_records - 1
243
246
else
244
247
i = i + 1
245
248
end
0 commit comments