Treat \xff\xff prefix as 'includePort' for get_addresses_for_key

This commit is contained in:
Andrew Noyes 2019-09-04 17:47:40 -07:00
parent bf0abeb31e
commit 11f6adf645
1 changed files with 7 additions and 1 deletions

View File

@ -2140,6 +2140,12 @@ Future< Void > Transaction::watch( Reference<Watch> watch ) {
ACTOR Future< Standalone< VectorRef< const char*>>> getAddressesForKeyActor( Key key, Future<Version> ver, Database cx, TransactionInfo info ) {
state vector<StorageServerInterface> ssi;
state bool includePort = false;
if (key.startsWith(LiteralStringRef("\xff\xff"))) {
key = key.removePrefix(LiteralStringRef("\xff\xff"));
includePort = true;
}
// If key >= allKeys.end, then getRange will return a kv-pair with an empty value. This will result in our serverInterfaces vector being empty, which will cause us to return an empty addresses list.
state Key ksKey = keyServersKey(key);
@ -2158,7 +2164,7 @@ ACTOR Future< Standalone< VectorRef< const char*>>> getAddressesForKeyActor( Key
Standalone<VectorRef<const char*>> addresses;
for (auto i : ssi) {
std::string ipString = i.address().ip.toString();
std::string ipString = includePort ? i.address().toString() : i.address().ip.toString();
char* c_string = new (addresses.arena()) char[ipString.length()+1];
strcpy(c_string, ipString.c_str());
addresses.push_back(addresses.arena(), c_string);