mirror of
https://github.com/OpenVPN/openvpn3.git
synced 2024-09-20 12:12:15 +02:00
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>
This commit is contained in:
parent
54e2d77f89
commit
2e3774c059
@ -334,9 +334,7 @@ namespace openvpn {
|
|||||||
{
|
{
|
||||||
// try to resolve item if needed
|
// try to resolve item if needed
|
||||||
auto& item = remote_list->list[index];
|
auto& item = remote_list->list[index];
|
||||||
bool item_in_use = item == remote_list->list[remote_list->item_index()]
|
if (item->need_resolve())
|
||||||
&& item->res_addr_list_defined();
|
|
||||||
if (item->need_resolve() && !item_in_use)
|
|
||||||
{
|
{
|
||||||
// next item to resolve
|
// next item to resolve
|
||||||
OPENVPN_LOG_REMOTELIST("*** BulkResolve RESOLVE on " << item->to_string());
|
OPENVPN_LOG_REMOTELIST("*** BulkResolve RESOLVE on " << item->to_string());
|
||||||
@ -365,6 +363,8 @@ namespace openvpn {
|
|||||||
{
|
{
|
||||||
if (notify_callback && index < remote_list->list.size())
|
if (notify_callback && index < remote_list->list.size())
|
||||||
{
|
{
|
||||||
|
auto indexed_item(remote_list->index.item());
|
||||||
|
const auto item_in_use(remote_list->list[indexed_item]);
|
||||||
const auto resolve_item(remote_list->list[index++]);
|
const auto resolve_item(remote_list->list[index++]);
|
||||||
if (!error)
|
if (!error)
|
||||||
{
|
{
|
||||||
@ -372,13 +372,15 @@ namespace openvpn {
|
|||||||
auto rand = remote_list->random ? remote_list->rng.get() : nullptr;
|
auto rand = remote_list->random ? remote_list->rng.get() : nullptr;
|
||||||
for (auto& item : remote_list->list)
|
for (auto& item : remote_list->list)
|
||||||
{
|
{
|
||||||
// Skip current, already resolved and items with different hostname
|
// Skip already resolved and items with different hostname
|
||||||
bool item_in_use = item == remote_list->list[remote_list->item_index()]
|
if (!item->need_resolve()
|
||||||
&& item->res_addr_list_defined();
|
|
||||||
if (item_in_use || !item->need_resolve()
|
|
||||||
|| item->server_host != resolve_item->server_host)
|
|| item->server_host != resolve_item->server_host)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// Reset item's address index as the list changes
|
||||||
|
if (item == item_in_use)
|
||||||
|
remote_list->index.reset_item_addr();
|
||||||
|
|
||||||
item->set_endpoint_range(results, rand, remote_list->cache_lifetime);
|
item->set_endpoint_range(results, rand, remote_list->cache_lifetime);
|
||||||
item->random_host = resolve_item->random_host;
|
item->random_host = resolve_item->random_host;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user