-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Remove the address_configured flag on tcp::resolver::query #1145
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
Conversation
The default behavior for tcp::resolver::query uses the address_configured flag, which only returns addresses if a non-loopback address is available on the system. If this is called before a real network interface is brought up, then resolution will fail and the server won't be functional, even for requests on the loopback interface. Explicitly set the flags to default so that the address_configured flag is not specified. This allows the server to start up normally even when the system has no active network interfaces.
| tcp::resolver resolver(service); | ||
| // #446: boost resolver does not recognize "+" as a host wildchar | ||
| tcp::resolver::query query = ("+" == m_host) ? tcp::resolver::query(m_port) : tcp::resolver::query(m_host, m_port); | ||
| tcp::resolver::query query = ("+" == m_host) ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to make this same PR!
The following would be shorter if it compiled cleanly everywhere?
- tcp::resolver::query query = ("+" == m_host) ? tcp::resolver::query(m_port) : tcp::resolver::query(m_host, m_port);
+ tcp::resolver::query query = ("+" == m_host) ? tcp::resolver::query(m_port, {}) : tcp::resolver::query(m_host, m_port, {});|
Is there any way to test this? I don't really know what this code is doing and without tests I'm worried we will regress this scenario for you in the future. |
|
This affects Boost.ASIO-based Another report, with the same fix, here: https://stackoverflow.com/a/5976632 |
|
Right, I trust the fix, I don't trust myself or a future maintainer to not unfix :) |
|
How can we help? :-) |
|
Thanks for your contribution! |
…ne that has no network interfaces configured (cf. microsoft/cpprestsdk#1145) (cherry picked from commit b7ff7e3d7b98c681673e4d4088b11147fbe7395e)
The default behavior for tcp::resolver::query uses the
address_configured flag, which only returns addresses if a non-loopback
address is available on the system. If this is called before a real network
interface is brought up, then resolution will fail and the server won't
be functional, even for requests on the loopback interface.
Explicitly set the flags to default so that the address_configured flag
is not specified. This allows the server to start up normally even when
the system has no active network interfaces.