0
0
mirror of https://github.com/yse/easy_profiler.git synced 2024-12-27 08:41:02 +08:00

Recreate socket on failed connection #154

This commit is contained in:
Sergey Yagovtsev 2019-03-27 00:07:58 +03:00
parent 0ccb564099
commit 3be797b4ad
2 changed files with 9 additions and 6 deletions

View File

@ -123,8 +123,10 @@ void EasySocket::flush()
if (m_socket) if (m_socket)
closeSocket(m_socket); closeSocket(m_socket);
if (m_replySocket != m_socket) if (m_replySocket != m_socket && m_replySocket != 0) {
// we do not need to close uninitialized reply socket
closeSocket(m_replySocket); closeSocket(m_replySocket);
}
#if defined(_WIN32) #if defined(_WIN32)
m_socket = 0; m_socket = 0;
@ -157,6 +159,9 @@ void EasySocket::checkResult(int result)
#if !defined(_WIN32) #if !defined(_WIN32)
case SOCK_BROKEN_PIPE: case SOCK_BROKEN_PIPE:
case SOCK_ENOENT: case SOCK_ENOENT:
#endif
#if defined (__APPLE__)
case ECONNREFUSED:
#endif #endif
m_state = ConnectionState::Disconnected; m_state = ConnectionState::Disconnected;
break; break;

View File

@ -2536,11 +2536,9 @@ void MainWindow::onConnectClicked(bool)
if (!m_listener.connect(address.toStdString().c_str(), port, reply)) if (!m_listener.connect(address.toStdString().c_str(), port, reply))
{ {
Dialog::warning(this, "Warning", QString("Cannot connect to %1").arg(address), QMessageBox::Close); Dialog::warning(this, "Warning", QString("Cannot connect to %1").arg(address), QMessageBox::Close);
if (EASY_GLOBALS.connected) // we need to close socket everytime on failed connection
{ m_listener.closeSocket();
m_listener.closeSocket(); setDisconnected(false);
setDisconnected(false);
}
if (!isSameAddress) if (!isSameAddress)
{ {