Remove the address_configured flag on tcp::resolver::query#1145
Merged
BillyONeal merged 2 commits intomicrosoft:masterfrom Jun 13, 2019
Merged
Remove the address_configured flag on tcp::resolver::query#1145BillyONeal merged 2 commits intomicrosoft:masterfrom
BillyONeal merged 2 commits intomicrosoft:masterfrom
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.
garethsb
approved these changes
Jun 6, 2019
| 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) ? |
Contributor
There was a problem hiding this comment.
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, {});
Member
|
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. |
Contributor
|
This affects Boost.ASIO-based Another report, with the same fix, here: https://stackoverflow.com/a/5976632 |
Member
|
Right, I trust the fix, I don't trust myself or a future maintainer to not unfix :) |
Contributor
|
How can we help? :-) |
Member
|
Thanks for your contribution! |
garethsb
added a commit
to sony/nmos-cpp
that referenced
this pull request
Jun 14, 2019
…ne that has no network interfaces configured (cf. microsoft/cpprestsdk#1145) (cherry picked from commit b7ff7e3d7b98c681673e4d4088b11147fbe7395e)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.