Commit e7828642 authored by Kenton Varda's avatar Kenton Varda

Fix bug where EzRpcClient would segfault if the target host resolved to multiple…

Fix bug where EzRpcClient would segfault if the target host resolved to multiple addresses and the connection to the first of those failed.
parent 9ea9e4cd
......@@ -72,6 +72,10 @@ private:
// =======================================================================================
kj::Promise<kj::Own<kj::AsyncIoStream>> connectAttach(kj::Own<kj::NetworkAddress>&& addr) {
return addr->connect().attach(kj::mv(addr));
}
struct EzRpcClient::Impl {
kj::Own<EzRpcContext> context;
......@@ -123,7 +127,7 @@ struct EzRpcClient::Impl {
setupPromise(context->getIoProvider().getNetwork()
.parseAddress(serverAddress, defaultPort)
.then([readerOpts](kj::Own<kj::NetworkAddress>&& addr) {
return addr->connect();
return connectAttach(kj::mv(addr));
}).then([this, readerOpts](kj::Own<kj::AsyncIoStream>&& stream) {
clientContext = kj::heap<ClientContext>(kj::mv(stream),
readerOpts);
......@@ -132,8 +136,9 @@ struct EzRpcClient::Impl {
Impl(const struct sockaddr* serverAddress, uint addrSize,
ReaderOptions readerOpts)
: context(EzRpcContext::getThreadLocal()),
setupPromise(context->getIoProvider().getNetwork()
.getSockaddr(serverAddress, addrSize)->connect()
setupPromise(
connectAttach(context->getIoProvider().getNetwork()
.getSockaddr(serverAddress, addrSize))
.then([this, readerOpts](kj::Own<kj::AsyncIoStream>&& stream) {
clientContext = kj::heap<ClientContext>(kj::mv(stream),
readerOpts);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment