diff --git a/cmd/synergyc/synergyc.cpp b/cmd/synergyc/synergyc.cpp index 7acd28bf..fd61bab7 100644 --- a/cmd/synergyc/synergyc.cpp +++ b/cmd/synergyc/synergyc.cpp @@ -66,7 +66,6 @@ public: m_backend(false), m_restartable(true), m_daemon(true), - m_camp(true), m_logFilter(NULL) { s_instance = this; } ~CArgs() { s_instance = NULL; } @@ -77,7 +76,6 @@ public: bool m_backend; bool m_restartable; bool m_daemon; - bool m_camp; const char* m_logFilter; CString m_name; CNetworkAddress m_serverAddress; @@ -168,7 +166,6 @@ realMain(void) try { // create client s_client = new CClient(ARG->m_name); - s_client->camp(ARG->m_camp); s_client->setAddress(ARG->m_serverAddress); s_client->setScreenFactory(new CSecondaryScreenFactory); s_client->setSocketFactory(new CTCPSocketFactory); @@ -212,6 +209,7 @@ realMain(void) catch (XScreenUnavailable& e) { // wait before retrying if we're going to retry if (ARG->m_restartable) { + LOG((CLOG_DEBUG "waiting %.0f seconds to retry", e.getRetryTime())); ARCH->sleep(e.getRetryTime()); } else { @@ -320,9 +318,6 @@ help() "\n" "Start the synergy mouse/keyboard sharing server.\n" "\n" -"* --camp keep attempting to connect to the server until\n" -" successful.\n" -" --no-camp do not camp.\n" " -d, --debug filter out log messages with priorty below level.\n" " level may be: FATAL, ERROR, WARNING, NOTE, INFO,\n" " DEBUG, DEBUG1, DEBUG2.\n" @@ -394,13 +389,11 @@ parse(int argc, const char* const* argv) } else if (isArg(i, argc, argv, NULL, "--camp")) { - // enable camping - ARG->m_camp = true; + // ignore -- included for backwards compatibility } else if (isArg(i, argc, argv, NULL, "--no-camp")) { - // disable camping - ARG->m_camp = false; + // ignore -- included for backwards compatibility } else if (isArg(i, argc, argv, "-f", "--no-daemon")) { diff --git a/lib/client/CClient.cpp b/lib/client/CClient.cpp index 82f73cd7..8ada1111 100644 --- a/lib/client/CClient.cpp +++ b/lib/client/CClient.cpp @@ -46,7 +46,6 @@ CClient::CClient(const CString& clientName) : m_name(clientName), m_screen(NULL), m_server(NULL), - m_camp(false), m_screenFactory(NULL), m_socketFactory(NULL), m_streamFilterFactory(NULL), @@ -65,13 +64,6 @@ CClient::~CClient() delete m_streamFilterFactory; } -void -CClient::camp(bool on) -{ - CLock lock(&m_mutex); - m_camp = on; -} - void CClient::setAddress(const CNetworkAddress& serverAddress) { @@ -217,14 +209,14 @@ CClient::open() { // open the screen try { - LOG((CLOG_INFO "opening screen")); + LOG((CLOG_DEBUG "opening screen")); openSecondaryScreen(); setStatus(kNotRunning); } catch (XScreenOpenFailure& e) { // can't open screen setStatus(kError, e.what()); - LOG((CLOG_INFO "failed to open screen")); + LOG((CLOG_DEBUG "failed to open screen")); throw; } } @@ -245,7 +237,7 @@ CClient::mainLoop() try { setStatus(kNotRunning); - LOG((CLOG_NOTE "starting client \"%s\"", m_name.c_str())); + LOG((CLOG_DEBUG "starting client \"%s\"", m_name.c_str())); // start server interactions { @@ -259,7 +251,7 @@ CClient::mainLoop() // clean up deleteSession(); - LOG((CLOG_NOTE "stopping client \"%s\"", m_name.c_str())); + LOG((CLOG_DEBUG "stopping client \"%s\"", m_name.c_str())); } catch (XMT& e) { LOG((CLOG_ERR "client error: %s", e.what())); @@ -267,7 +259,7 @@ CClient::mainLoop() // clean up deleteSession(); - LOG((CLOG_NOTE "stopping client \"%s\"", m_name.c_str())); + LOG((CLOG_DEBUG "stopping client \"%s\"", m_name.c_str())); throw; } catch (XBase& e) { @@ -276,7 +268,7 @@ CClient::mainLoop() // clean up deleteSession(); - LOG((CLOG_NOTE "stopping client \"%s\"", m_name.c_str())); + LOG((CLOG_DEBUG "stopping client \"%s\"", m_name.c_str())); CLock lock(&m_mutex); m_rejected = false; } @@ -285,16 +277,16 @@ CClient::mainLoop() // clean up deleteSession(); - LOG((CLOG_NOTE "stopping client \"%s\"", m_name.c_str())); + LOG((CLOG_DEBUG "stopping client \"%s\"", m_name.c_str())); throw; } catch (...) { - LOG((CLOG_DEBUG "unknown client error")); + LOG((CLOG_ERR "client error: ")); setStatus(kError); // clean up deleteSession(); - LOG((CLOG_NOTE "stopping client \"%s\"", m_name.c_str())); + LOG((CLOG_DEBUG "stopping client \"%s\"", m_name.c_str())); throw; } } @@ -303,7 +295,7 @@ void CClient::close() { closeSecondaryScreen(); - LOG((CLOG_INFO "closed screen")); + LOG((CLOG_DEBUG "closed screen")); } void @@ -587,40 +579,21 @@ CClient::runServer() CServerProxy* proxy = NULL; bool timedOut; try { - for (;;) { - try { - // allow connect this much time to succeed - CTimerThread timer(15.0, &timedOut); + // allow connect and handshake this much time to succeed + CTimerThread timer(15.0, &timedOut); - // create socket and attempt to connect to server - LOG((CLOG_DEBUG1 "connecting to server")); - if (m_socketFactory != NULL) { - socket = m_socketFactory->create(); - } - assert(socket != NULL); - socket->connect(m_serverAddress); - LOG((CLOG_INFO "connected to server")); - break; - } - catch (XSocketConnect& e) { - setStatus(kError, e.what()); - LOG((CLOG_DEBUG "failed to connect to server: %s", e.what())); - - // failed to connect. if not camping then rethrow. - if (!m_camp) { - throw; - } - - // we're camping. wait a bit before retrying - ARCH->sleep(15.0); - } + // create socket and attempt to connect to server + LOG((CLOG_DEBUG1 "connecting to server")); + if (m_socketFactory != NULL) { + socket = m_socketFactory->create(); } + assert(socket != NULL); + socket->connect(m_serverAddress); // create proxy + LOG((CLOG_INFO "connected to server")); LOG((CLOG_DEBUG1 "negotiating with server")); proxy = handshakeServer(socket); - CLock lock(&m_mutex); - m_server = proxy; } catch (XThread&) { if (timedOut) { @@ -630,24 +603,37 @@ CClient::runServer() else { // cancelled by some thread other than the timer } + delete proxy; delete socket; throw; } + catch (XSocketConnect& e) { + LOG((CLOG_ERR "connection failed: %s", e.what())); + setStatus(kError, e.what()); + delete socket; + return; + } catch (XBase& e) { LOG((CLOG_ERR "connection failed: %s", e.what())); setStatus(kError, e.what()); - LOG((CLOG_DEBUG "disconnecting from server")); + LOG((CLOG_INFO "disconnecting from server")); delete socket; return; } catch (...) { LOG((CLOG_ERR "connection failed: ")); setStatus(kError); - LOG((CLOG_DEBUG "disconnecting from server")); + LOG((CLOG_INFO "disconnecting from server")); delete socket; return; } + // saver server proxy object + { + CLock lock(&m_mutex); + m_server = proxy; + } + try { // prepare for remote control m_screen->remoteControl(); @@ -709,9 +695,6 @@ CClient::handshakeServer(IDataSocket* socket) CServerProxy* proxy = NULL; try { - // give handshake some time - CTimerThread timer(30.0); - // wait for hello from server LOG((CLOG_DEBUG1 "wait for hello")); SInt16 major, minor; diff --git a/lib/client/CClient.h b/lib/client/CClient.h index 61efddaa..5647e7e3 100644 --- a/lib/client/CClient.h +++ b/lib/client/CClient.h @@ -54,15 +54,6 @@ public: //! @name manipulators //@{ - //! Set camping state - /*! - Turns camping on or off. When camping the client will keep - trying to connect to the server until it succeeds. This - is useful if the client may start before the server. Do - not call this while in mainLoop(). - */ - void camp(bool on); - //! Set server address /*! Sets the server's address that the client should connect to. @@ -196,7 +187,6 @@ private: CSecondaryScreen* m_screen; IScreenReceiver* m_server; CNetworkAddress m_serverAddress; - bool m_camp; ISecondaryScreenFactory* m_screenFactory; ISocketFactory* m_socketFactory; IStreamFilterFactory* m_streamFilterFactory; diff --git a/lib/platform/CMSWindowsScreen.cpp b/lib/platform/CMSWindowsScreen.cpp index 5facb08b..e42e91b1 100644 --- a/lib/platform/CMSWindowsScreen.cpp +++ b/lib/platform/CMSWindowsScreen.cpp @@ -441,7 +441,7 @@ CMSWindowsScreen::updateScreenShape() m_y = GetSystemMetrics(SM_YVIRTUALSCREEN); m_w = GetSystemMetrics(SM_CXVIRTUALSCREEN); m_h = GetSystemMetrics(SM_CYVIRTUALSCREEN); - LOG((CLOG_INFO "screen shape: %d,%d %dx%d", m_x, m_y, m_w, m_h)); + LOG((CLOG_DEBUG "screen shape: %d,%d %dx%d", m_x, m_y, m_w, m_h)); // check for multiple monitors m_multimon = (m_w != GetSystemMetrics(SM_CXSCREEN) || @@ -508,7 +508,7 @@ CMSWindowsScreen::onPreDispatch(const CEvent* event) // if the desktop was inaccessible then notify the // event handler of that. if (m_inaccessibleDesktop) { - LOG((CLOG_INFO "desktop is now accessible")); + LOG((CLOG_DEBUG "desktop is now accessible")); m_inaccessibleDesktop = false; m_eventHandler->onAccessibleDesktop(); } @@ -516,7 +516,7 @@ CMSWindowsScreen::onPreDispatch(const CEvent* event) else if (!m_inaccessibleDesktop) { // the desktop has become inaccessible m_inaccessibleDesktop = true; - LOG((CLOG_INFO "desktop is now inaccessible")); + LOG((CLOG_DEBUG "desktop is now inaccessible")); } } @@ -674,7 +674,7 @@ CMSWindowsScreen::switchDesktop(HDESK desk) // if no new desktop then we're done if (desk == NULL) { - LOG((CLOG_INFO "disconnecting desktop")); + LOG((CLOG_DEBUG "disconnecting desktop")); return true; } @@ -730,7 +730,7 @@ CMSWindowsScreen::switchDesktop(HDESK desk) // save new desktop m_desk = desk; m_deskName = getDesktopName(m_desk); - LOG((CLOG_INFO "switched to desktop \"%s\"", m_deskName.c_str())); + LOG((CLOG_DEBUG "switched to desktop \"%s\"", m_deskName.c_str())); // let client prepare the window m_eventHandler->postCreateWindow(m_window); diff --git a/lib/platform/CXWindowsScreen.cpp b/lib/platform/CXWindowsScreen.cpp index 964fe739..870da6dc 100644 --- a/lib/platform/CXWindowsScreen.cpp +++ b/lib/platform/CXWindowsScreen.cpp @@ -590,7 +590,7 @@ CXWindowsScreen::updateScreenShape() m_y = 0; m_w = WidthOfScreen(DefaultScreenOfDisplay(m_display)); m_h = HeightOfScreen(DefaultScreenOfDisplay(m_display)); - LOG((CLOG_INFO "screen shape: %d,%d %dx%d", m_x, m_y, m_w, m_h)); + LOG((CLOG_DEBUG "screen shape: %d,%d %dx%d", m_x, m_y, m_w, m_h)); // get center of default screen m_xCenter = m_x + (m_w >> 1);