diff --git a/src/lib/base/EventTypes.cpp b/src/lib/base/EventTypes.cpp index 5ef90e8d..d317e1d7 100644 --- a/src/lib/base/EventTypes.cpp +++ b/src/lib/base/EventTypes.cpp @@ -95,6 +95,7 @@ REGISTER_EVENT(IListenSocket, connecting) // REGISTER_EVENT(ISocket, disconnected) +REGISTER_EVENT(ISocket, stopRetry) // // OSXScreen diff --git a/src/lib/base/EventTypes.h b/src/lib/base/EventTypes.h index dc605f21..74bbed63 100644 --- a/src/lib/base/EventTypes.h +++ b/src/lib/base/EventTypes.h @@ -281,7 +281,8 @@ private: class ISocketEvents : public EventTypes { public: ISocketEvents() : - m_disconnected(Event::kUnknown) { } + m_disconnected(Event::kUnknown), + m_stopRetry(Event::kUnknown) { } //! @name accessors //@{ @@ -294,10 +295,18 @@ public: */ Event::Type disconnected(); + //! Get stop retry event type + /*! + Returns the stop retry event type. This is sent when the client + doesn't want to reconnect after it disconnects from the server. + */ + Event::Type stopRetry(); + //@} private: Event::Type m_disconnected; + Event::Type m_stopRetry; }; class OSXScreenEvents : public EventTypes { diff --git a/src/lib/client/Client.cpp b/src/lib/client/Client.cpp index 9c7d785d..3e59c942 100644 --- a/src/lib/client/Client.cpp +++ b/src/lib/client/Client.cpp @@ -60,7 +60,7 @@ Client::Client( const String& name, const NetworkAddress& address, ISocketFactory* socketFactory, synergy::Screen* screen, - ClientArgs args) : + ClientArgs& args) : m_mock(false), m_name(name), m_serverAddress(address), @@ -470,6 +470,10 @@ Client::setupConnection() m_stream->getEventTarget(), new TMethodEventJob(this, &Client::handleDisconnected)); + + m_events->adoptHandler(m_events->forISocket().stopRetry(), + m_stream->getEventTarget(), + new TMethodEventJob(this, &Client::handleStopRetry)); } void @@ -525,6 +529,8 @@ Client::cleanupConnection() m_stream->getEventTarget()); m_events->removeHandler(m_events->forISocket().disconnected(), m_stream->getEventTarget()); + m_events->removeHandler(m_events->forISocket().stopRetry(), + m_stream->getEventTarget()); cleanupStream(); } } @@ -743,6 +749,11 @@ Client::onFileRecieveCompleted() } } +void +Client::handleStopRetry(const Event&, void*) +{ + m_args.m_restartable = false; +} void Client::writeToDropDirThread(void*) diff --git a/src/lib/client/Client.h b/src/lib/client/Client.h index e50b567b..c3bdfaba 100644 --- a/src/lib/client/Client.h +++ b/src/lib/client/Client.h @@ -60,7 +60,7 @@ public: const String& name, const NetworkAddress& address, ISocketFactory* socketFactory, synergy::Screen* screen, - ClientArgs args); + ClientArgs& args); ~Client(); #ifdef TEST_ENV @@ -196,6 +196,7 @@ private: void handleResume(const Event& event, void*); void handleFileChunkSending(const Event&, void*); void handleFileRecieveCompleted(const Event&, void*); + void handleStopRetry(const Event&, void*); void onFileRecieveCompleted(); public: @@ -226,5 +227,5 @@ private: Thread* m_writeToDropDirThread; TCPSocket* m_socket; bool m_useSecureNetwork; - ClientArgs m_args; + ClientArgs& m_args; }; diff --git a/src/lib/plugin/ns/SecureSocket.cpp b/src/lib/plugin/ns/SecureSocket.cpp index c878871d..ccc3ec01 100644 --- a/src/lib/plugin/ns/SecureSocket.cpp +++ b/src/lib/plugin/ns/SecureSocket.cpp @@ -281,10 +281,8 @@ SecureSocket::secureConnect(int socket) checkResult(r, fatal, retry); if (fatal) { - // tell user and sleep so the socket isn't hammered. LOG((CLOG_ERR "failed to connect secure socket")); LOG((CLOG_INFO "server connection may not be secure")); - disconnect(); return false; } @@ -299,6 +297,7 @@ SecureSocket::secureConnect(int socket) } else { LOG((CLOG_ERR "failed to verify server certificate fingerprint")); + sendEvent(getEvents()->forISocket().stopRetry()); disconnect(); } } diff --git a/src/lib/synergy/ClientApp.cpp b/src/lib/synergy/ClientApp.cpp index f27a8331..dd262a93 100644 --- a/src/lib/synergy/ClientApp.cpp +++ b/src/lib/synergy/ClientApp.cpp @@ -331,7 +331,6 @@ ClientApp::handleClientDisconnected(const Event&, void*) updateStatus(); } - Client* ClientApp::openClient(const String& name, const NetworkAddress& address, synergy::Screen* screen)