mirror of
https://github.com/pocoproject/poco.git
synced 2025-03-28 01:21:31 +01:00
Fix in close and open (#1911)
* Fix in close and open close(): fix possible throw on broken socket that could lead in CLOSE_WAIT leak (especially under linux OS) open(): fix open function to deal with control socket created from outside and login without user * Fix FTPSClientSession ctor * fix: check if controlsocket is valid * removed read server reply with no username If we read server reply with no username, we can end up with a throw (if server reply is negative) and the testLoginFailed1 fail
This commit is contained in:
parent
6e69babf2e
commit
c4f0727bc7
@ -132,8 +132,12 @@ void FTPClientSession::open(const std::string& host,
|
||||
}
|
||||
else
|
||||
{
|
||||
_pControlSocket = new DialogSocket(SocketAddress(_host, _port));
|
||||
_pControlSocket->setReceiveTimeout(_timeout);
|
||||
if (!_pControlSocket)
|
||||
{
|
||||
_pControlSocket = new DialogSocket(SocketAddress(_host, _port));
|
||||
_pControlSocket->setReceiveTimeout(_timeout);
|
||||
}
|
||||
receiveServerReadyReply();
|
||||
}
|
||||
}
|
||||
|
||||
@ -182,20 +186,24 @@ void FTPClientSession::logout()
|
||||
{
|
||||
try { endTransfer(); }
|
||||
catch (...) { }
|
||||
std::string response;
|
||||
sendCommand("QUIT", response);
|
||||
_isLoggedIn = false;
|
||||
std::string response;
|
||||
sendCommand("QUIT", response);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FTPClientSession::close()
|
||||
{
|
||||
logout();
|
||||
_pControlSocket->close();
|
||||
delete _pControlSocket;
|
||||
_pControlSocket = 0;
|
||||
try { logout(); }
|
||||
catch(...){ }
|
||||
_serverReady = false;
|
||||
if (_pControlSocket)
|
||||
{
|
||||
_pControlSocket->close();
|
||||
delete _pControlSocket;
|
||||
_pControlSocket = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -41,10 +41,8 @@ FTPSClientSession::FTPSClientSession(const std::string& host,
|
||||
Poco::UInt16 port,
|
||||
const std::string& username,
|
||||
const std::string& password) :
|
||||
FTPClientSession(host, port)
|
||||
FTPClientSession(host, port, username, password)
|
||||
{
|
||||
if(!username.empty())
|
||||
login(username, password);
|
||||
}
|
||||
|
||||
void FTPSClientSession::tryFTPSmode(bool bTryFTPS)
|
||||
|
Loading…
x
Reference in New Issue
Block a user