Skip to content

Commit 2e3774c

Browse files
committed
RemoteList: don't ignore item in use in BulkResolve
Remove the exception for the item in use when re-resolving a RemoteList. This can be done now, that Item are referred to with a smart pointer instead of a direct reference from extern. Instead reset the address index for that item, so that it doesn't point to a potentially non-existent address. Signed-off-by: Heiko Hund <heiko@openvpn.net>
1 parent 54e2d77 commit 2e3774c

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

openvpn/client/remotelist.hpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -334,9 +334,7 @@ namespace openvpn {
334334
{
335335
// try to resolve item if needed
336336
auto& item = remote_list->list[index];
337-
bool item_in_use = item == remote_list->list[remote_list->item_index()]
338-
&& item->res_addr_list_defined();
339-
if (item->need_resolve() && !item_in_use)
337+
if (item->need_resolve())
340338
{
341339
// next item to resolve
342340
OPENVPN_LOG_REMOTELIST("*** BulkResolve RESOLVE on " << item->to_string());
@@ -365,20 +363,24 @@ namespace openvpn {
365363
{
366364
if (notify_callback && index < remote_list->list.size())
367365
{
366+
auto indexed_item(remote_list->index.item());
367+
const auto item_in_use(remote_list->list[indexed_item]);
368368
const auto resolve_item(remote_list->list[index++]);
369369
if (!error)
370370
{
371371
// Set results to Items, where applicable
372372
auto rand = remote_list->random ? remote_list->rng.get() : nullptr;
373373
for (auto& item : remote_list->list)
374374
{
375-
// Skip current, already resolved and items with different hostname
376-
bool item_in_use = item == remote_list->list[remote_list->item_index()]
377-
&& item->res_addr_list_defined();
378-
if (item_in_use || !item->need_resolve()
375+
// Skip already resolved and items with different hostname
376+
if (!item->need_resolve()
379377
|| item->server_host != resolve_item->server_host)
380378
continue;
381379

380+
// Reset item's address index as the list changes
381+
if (item == item_in_use)
382+
remote_list->index.reset_item_addr();
383+
382384
item->set_endpoint_range(results, rand, remote_list->cache_lifetime);
383385
item->random_host = resolve_item->random_host;
384386
}

0 commit comments

Comments
 (0)