Merge pull request #116 from WebFreak001/fix-115

release ref on failing connectTCP
This commit is contained in:
Sönke Ludwig 2019-01-19 15:06:39 +01:00 committed by GitHub
commit 568cdb112b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 1 deletions

View file

@ -215,7 +215,16 @@ TCPConnection connectTCP(NetworkAddress addr, NetworkAddress bind_address = anyA
enforce(!cancelled, "Failed to connect to " ~ addr.toString() ~
": timeout");
enforce(status == ConnectStatus.connected, "Failed to connect to "~addr.toString()~": "~status.to!string);
if (status != ConnectStatus.connected) {
if (sock != SocketFD.invalid) {
bool refsLeft = eventDriver.sockets.releaseRef(sock);
assert(!refsLeft);
}
enforce(false, "Failed to connect to "~addr.toString()~": "~status.to!string);
assert(false);
}
return TCPConnection(sock, uaddr);
} ();