|
|
@ -66,19 +66,21 @@ void TCPConnecter::Connect()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (auto iter = _tcp_connecters.begin(); iter < _tcp_connecters.end(); /* nothing */) {
|
|
|
|
for (auto iter = _tcp_connecters.begin(); iter < _tcp_connecters.end(); /* nothing */) {
|
|
|
|
TCPConnecter *cur = *iter;
|
|
|
|
TCPConnecter *cur = *iter;
|
|
|
|
if ((cur->connected || cur->aborted) && cur->killed) {
|
|
|
|
const bool connected = cur->connected.load();
|
|
|
|
|
|
|
|
const bool aborted = cur->aborted.load();
|
|
|
|
|
|
|
|
if ((connected || aborted) && cur->killed) {
|
|
|
|
iter = _tcp_connecters.erase(iter);
|
|
|
|
iter = _tcp_connecters.erase(iter);
|
|
|
|
if (cur->sock != INVALID_SOCKET) closesocket(cur->sock);
|
|
|
|
if (cur->sock != INVALID_SOCKET) closesocket(cur->sock);
|
|
|
|
delete cur;
|
|
|
|
delete cur;
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (cur->connected) {
|
|
|
|
if (connected) {
|
|
|
|
iter = _tcp_connecters.erase(iter);
|
|
|
|
iter = _tcp_connecters.erase(iter);
|
|
|
|
cur->OnConnect(cur->sock);
|
|
|
|
cur->OnConnect(cur->sock);
|
|
|
|
delete cur;
|
|
|
|
delete cur;
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (cur->aborted) {
|
|
|
|
if (aborted) {
|
|
|
|
iter = _tcp_connecters.erase(iter);
|
|
|
|
iter = _tcp_connecters.erase(iter);
|
|
|
|
cur->OnFailure();
|
|
|
|
cur->OnFailure();
|
|
|
|
delete cur;
|
|
|
|
delete cur;
|
|
|
|