Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DNS.resolve() should not be sorted in HostEntry::removeDuplicates() #3807

Closed
lingyphone opened this issue Sep 20, 2022 · 5 comments
Closed

Comments

@lingyphone
Copy link

lingyphone commented Sep 20, 2022

It is caused by commit 8030564#diff-b38b1a4ab2c3fa8c175cff4b6f7c55e7ce4cd720f423e0a2b91d88b8f472f3cc

And it ruins the DNS round-robin or DNS load-balance

@github-actions
Copy link

This issue is stale because it has been open for 365 days with no activity.

@github-actions github-actions bot added the stale label Sep 21, 2023
Copy link

This issue was closed because it has been inactive for 60 days since being marked as stale.

@matejk
Copy link
Contributor

matejk commented Jan 17, 2024

@lingyphone: is this issue still relevant?

@aleks-f
Copy link
Member

aleks-f commented Jan 17, 2024

@matejk yes, because of this. we should find another way to get rid of duplicates (and hope nobody found a reason to rely on it being ordered by now)

@aleks-f aleks-f changed the title Please fix the should-not-be-sorted DNS.resolve() returns in new added HostEntry::removeDuplicates() DNS.resolve() should not be sorted in HostEntry::removeDuplicates() Jan 17, 2024
@rtoelhoej
Copy link

rtoelhoej commented Feb 22, 2024

@aleks-f, @matejk
The sorting in removeDuplicates breaks DNS round-robin and DNS load-balance for our project as well.

We did tests and on Linux multiple IP's are returned with same value on Windows it doesn't return any duplicates, so it looks like removeDuplicates is a Unix/Linux fix.

A fix would be to change the removeDuplicates to remove without sorting, I think sorting was used because it's the easiest way to remove duplicates. (std::unique only checks next item in list, it doesn't check the whole list, so it requires the vector to be sorted.

Fix in Net\include\Poco\Net\HostEntry.h by updating removeDuplicates to use std::set/std::remove_if:

template <typename C>
void removeDuplicates(C& list)
{
	std::set<T> values;
	list.erase(std::remove_if(list.begin(), list.end(), [&](const T& value) { return !values.insert(value).second; }), list.end());
}

@matejk matejk added this to the Release 1.13.3 milestone Feb 22, 2024
@matejk matejk self-assigned this Feb 22, 2024
@matejk matejk added this to 1.13 Feb 22, 2024
@matejk matejk reopened this Feb 22, 2024
@github-actions github-actions bot removed the stale label Feb 23, 2024
@matejk matejk moved this to In Progress in 1.13 Feb 28, 2024
@matejk matejk closed this as completed in c624b27 Feb 28, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in 1.13 Feb 28, 2024
@matejk matejk added the fixed label Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
Development

No branches or pull requests

4 participants