Prevent INFO level log messages when client is repeatedly trying

to connect.  This prevents a log from filling up while the client
can't connect for no useful reason.  Also removed --camp option
and cleaned up handling of client connection.  Users must now use
--restart instead of --camp.
This commit is contained in:
crs 2003-07-12 17:57:31 +00:00
parent f27fd7b021
commit 476faea8ab
5 changed files with 43 additions and 77 deletions

View File

@ -66,7 +66,6 @@ public:
m_backend(false), m_backend(false),
m_restartable(true), m_restartable(true),
m_daemon(true), m_daemon(true),
m_camp(true),
m_logFilter(NULL) m_logFilter(NULL)
{ s_instance = this; } { s_instance = this; }
~CArgs() { s_instance = NULL; } ~CArgs() { s_instance = NULL; }
@ -77,7 +76,6 @@ public:
bool m_backend; bool m_backend;
bool m_restartable; bool m_restartable;
bool m_daemon; bool m_daemon;
bool m_camp;
const char* m_logFilter; const char* m_logFilter;
CString m_name; CString m_name;
CNetworkAddress m_serverAddress; CNetworkAddress m_serverAddress;
@ -168,7 +166,6 @@ realMain(void)
try { try {
// create client // create client
s_client = new CClient(ARG->m_name); s_client = new CClient(ARG->m_name);
s_client->camp(ARG->m_camp);
s_client->setAddress(ARG->m_serverAddress); s_client->setAddress(ARG->m_serverAddress);
s_client->setScreenFactory(new CSecondaryScreenFactory); s_client->setScreenFactory(new CSecondaryScreenFactory);
s_client->setSocketFactory(new CTCPSocketFactory); s_client->setSocketFactory(new CTCPSocketFactory);
@ -212,6 +209,7 @@ realMain(void)
catch (XScreenUnavailable& e) { catch (XScreenUnavailable& e) {
// wait before retrying if we're going to retry // wait before retrying if we're going to retry
if (ARG->m_restartable) { if (ARG->m_restartable) {
LOG((CLOG_DEBUG "waiting %.0f seconds to retry", e.getRetryTime()));
ARCH->sleep(e.getRetryTime()); ARCH->sleep(e.getRetryTime());
} }
else { else {
@ -320,9 +318,6 @@ help()
"\n" "\n"
"Start the synergy mouse/keyboard sharing server.\n" "Start the synergy mouse/keyboard sharing server.\n"
"\n" "\n"
"* --camp keep attempting to connect to the server until\n"
" successful.\n"
" --no-camp do not camp.\n"
" -d, --debug <level> filter out log messages with priorty below level.\n" " -d, --debug <level> filter out log messages with priorty below level.\n"
" level may be: FATAL, ERROR, WARNING, NOTE, INFO,\n" " level may be: FATAL, ERROR, WARNING, NOTE, INFO,\n"
" DEBUG, DEBUG1, DEBUG2.\n" " DEBUG, DEBUG1, DEBUG2.\n"
@ -394,13 +389,11 @@ parse(int argc, const char* const* argv)
} }
else if (isArg(i, argc, argv, NULL, "--camp")) { else if (isArg(i, argc, argv, NULL, "--camp")) {
// enable camping // ignore -- included for backwards compatibility
ARG->m_camp = true;
} }
else if (isArg(i, argc, argv, NULL, "--no-camp")) { else if (isArg(i, argc, argv, NULL, "--no-camp")) {
// disable camping // ignore -- included for backwards compatibility
ARG->m_camp = false;
} }
else if (isArg(i, argc, argv, "-f", "--no-daemon")) { else if (isArg(i, argc, argv, "-f", "--no-daemon")) {

View File

@ -46,7 +46,6 @@ CClient::CClient(const CString& clientName) :
m_name(clientName), m_name(clientName),
m_screen(NULL), m_screen(NULL),
m_server(NULL), m_server(NULL),
m_camp(false),
m_screenFactory(NULL), m_screenFactory(NULL),
m_socketFactory(NULL), m_socketFactory(NULL),
m_streamFilterFactory(NULL), m_streamFilterFactory(NULL),
@ -65,13 +64,6 @@ CClient::~CClient()
delete m_streamFilterFactory; delete m_streamFilterFactory;
} }
void
CClient::camp(bool on)
{
CLock lock(&m_mutex);
m_camp = on;
}
void void
CClient::setAddress(const CNetworkAddress& serverAddress) CClient::setAddress(const CNetworkAddress& serverAddress)
{ {
@ -217,14 +209,14 @@ CClient::open()
{ {
// open the screen // open the screen
try { try {
LOG((CLOG_INFO "opening screen")); LOG((CLOG_DEBUG "opening screen"));
openSecondaryScreen(); openSecondaryScreen();
setStatus(kNotRunning); setStatus(kNotRunning);
} }
catch (XScreenOpenFailure& e) { catch (XScreenOpenFailure& e) {
// can't open screen // can't open screen
setStatus(kError, e.what()); setStatus(kError, e.what());
LOG((CLOG_INFO "failed to open screen")); LOG((CLOG_DEBUG "failed to open screen"));
throw; throw;
} }
} }
@ -245,7 +237,7 @@ CClient::mainLoop()
try { try {
setStatus(kNotRunning); 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 // start server interactions
{ {
@ -259,7 +251,7 @@ CClient::mainLoop()
// clean up // clean up
deleteSession(); deleteSession();
LOG((CLOG_NOTE "stopping client \"%s\"", m_name.c_str())); LOG((CLOG_DEBUG "stopping client \"%s\"", m_name.c_str()));
} }
catch (XMT& e) { catch (XMT& e) {
LOG((CLOG_ERR "client error: %s", e.what())); LOG((CLOG_ERR "client error: %s", e.what()));
@ -267,7 +259,7 @@ CClient::mainLoop()
// clean up // clean up
deleteSession(); deleteSession();
LOG((CLOG_NOTE "stopping client \"%s\"", m_name.c_str())); LOG((CLOG_DEBUG "stopping client \"%s\"", m_name.c_str()));
throw; throw;
} }
catch (XBase& e) { catch (XBase& e) {
@ -276,7 +268,7 @@ CClient::mainLoop()
// clean up // clean up
deleteSession(); 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); CLock lock(&m_mutex);
m_rejected = false; m_rejected = false;
} }
@ -285,16 +277,16 @@ CClient::mainLoop()
// clean up // clean up
deleteSession(); deleteSession();
LOG((CLOG_NOTE "stopping client \"%s\"", m_name.c_str())); LOG((CLOG_DEBUG "stopping client \"%s\"", m_name.c_str()));
throw; throw;
} }
catch (...) { catch (...) {
LOG((CLOG_DEBUG "unknown client error")); LOG((CLOG_ERR "client error: <unknown error>"));
setStatus(kError); setStatus(kError);
// clean up // clean up
deleteSession(); deleteSession();
LOG((CLOG_NOTE "stopping client \"%s\"", m_name.c_str())); LOG((CLOG_DEBUG "stopping client \"%s\"", m_name.c_str()));
throw; throw;
} }
} }
@ -303,7 +295,7 @@ void
CClient::close() CClient::close()
{ {
closeSecondaryScreen(); closeSecondaryScreen();
LOG((CLOG_INFO "closed screen")); LOG((CLOG_DEBUG "closed screen"));
} }
void void
@ -587,9 +579,7 @@ CClient::runServer()
CServerProxy* proxy = NULL; CServerProxy* proxy = NULL;
bool timedOut; bool timedOut;
try { try {
for (;;) { // allow connect and handshake this much time to succeed
try {
// allow connect this much time to succeed
CTimerThread timer(15.0, &timedOut); CTimerThread timer(15.0, &timedOut);
// create socket and attempt to connect to server // create socket and attempt to connect to server
@ -599,28 +589,11 @@ CClient::runServer()
} }
assert(socket != NULL); assert(socket != NULL);
socket->connect(m_serverAddress); 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 proxy // create proxy
LOG((CLOG_INFO "connected to server"));
LOG((CLOG_DEBUG1 "negotiating with server")); LOG((CLOG_DEBUG1 "negotiating with server"));
proxy = handshakeServer(socket); proxy = handshakeServer(socket);
CLock lock(&m_mutex);
m_server = proxy;
} }
catch (XThread&) { catch (XThread&) {
if (timedOut) { if (timedOut) {
@ -630,24 +603,37 @@ CClient::runServer()
else { else {
// cancelled by some thread other than the timer // cancelled by some thread other than the timer
} }
delete proxy;
delete socket; delete socket;
throw; throw;
} }
catch (XSocketConnect& e) {
LOG((CLOG_ERR "connection failed: %s", e.what()));
setStatus(kError, e.what());
delete socket;
return;
}
catch (XBase& e) { catch (XBase& e) {
LOG((CLOG_ERR "connection failed: %s", e.what())); LOG((CLOG_ERR "connection failed: %s", e.what()));
setStatus(kError, e.what()); setStatus(kError, e.what());
LOG((CLOG_DEBUG "disconnecting from server")); LOG((CLOG_INFO "disconnecting from server"));
delete socket; delete socket;
return; return;
} }
catch (...) { catch (...) {
LOG((CLOG_ERR "connection failed: <unknown error>")); LOG((CLOG_ERR "connection failed: <unknown error>"));
setStatus(kError); setStatus(kError);
LOG((CLOG_DEBUG "disconnecting from server")); LOG((CLOG_INFO "disconnecting from server"));
delete socket; delete socket;
return; return;
} }
// saver server proxy object
{
CLock lock(&m_mutex);
m_server = proxy;
}
try { try {
// prepare for remote control // prepare for remote control
m_screen->remoteControl(); m_screen->remoteControl();
@ -709,9 +695,6 @@ CClient::handshakeServer(IDataSocket* socket)
CServerProxy* proxy = NULL; CServerProxy* proxy = NULL;
try { try {
// give handshake some time
CTimerThread timer(30.0);
// wait for hello from server // wait for hello from server
LOG((CLOG_DEBUG1 "wait for hello")); LOG((CLOG_DEBUG1 "wait for hello"));
SInt16 major, minor; SInt16 major, minor;

View File

@ -54,15 +54,6 @@ public:
//! @name manipulators //! @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 //! Set server address
/*! /*!
Sets the server's address that the client should connect to. Sets the server's address that the client should connect to.
@ -196,7 +187,6 @@ private:
CSecondaryScreen* m_screen; CSecondaryScreen* m_screen;
IScreenReceiver* m_server; IScreenReceiver* m_server;
CNetworkAddress m_serverAddress; CNetworkAddress m_serverAddress;
bool m_camp;
ISecondaryScreenFactory* m_screenFactory; ISecondaryScreenFactory* m_screenFactory;
ISocketFactory* m_socketFactory; ISocketFactory* m_socketFactory;
IStreamFilterFactory* m_streamFilterFactory; IStreamFilterFactory* m_streamFilterFactory;

View File

@ -441,7 +441,7 @@ CMSWindowsScreen::updateScreenShape()
m_y = GetSystemMetrics(SM_YVIRTUALSCREEN); m_y = GetSystemMetrics(SM_YVIRTUALSCREEN);
m_w = GetSystemMetrics(SM_CXVIRTUALSCREEN); m_w = GetSystemMetrics(SM_CXVIRTUALSCREEN);
m_h = GetSystemMetrics(SM_CYVIRTUALSCREEN); 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 // check for multiple monitors
m_multimon = (m_w != GetSystemMetrics(SM_CXSCREEN) || m_multimon = (m_w != GetSystemMetrics(SM_CXSCREEN) ||
@ -508,7 +508,7 @@ CMSWindowsScreen::onPreDispatch(const CEvent* event)
// if the desktop was inaccessible then notify the // if the desktop was inaccessible then notify the
// event handler of that. // event handler of that.
if (m_inaccessibleDesktop) { if (m_inaccessibleDesktop) {
LOG((CLOG_INFO "desktop is now accessible")); LOG((CLOG_DEBUG "desktop is now accessible"));
m_inaccessibleDesktop = false; m_inaccessibleDesktop = false;
m_eventHandler->onAccessibleDesktop(); m_eventHandler->onAccessibleDesktop();
} }
@ -516,7 +516,7 @@ CMSWindowsScreen::onPreDispatch(const CEvent* event)
else if (!m_inaccessibleDesktop) { else if (!m_inaccessibleDesktop) {
// the desktop has become inaccessible // the desktop has become inaccessible
m_inaccessibleDesktop = true; 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 no new desktop then we're done
if (desk == NULL) { if (desk == NULL) {
LOG((CLOG_INFO "disconnecting desktop")); LOG((CLOG_DEBUG "disconnecting desktop"));
return true; return true;
} }
@ -730,7 +730,7 @@ CMSWindowsScreen::switchDesktop(HDESK desk)
// save new desktop // save new desktop
m_desk = desk; m_desk = desk;
m_deskName = getDesktopName(m_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 // let client prepare the window
m_eventHandler->postCreateWindow(m_window); m_eventHandler->postCreateWindow(m_window);

View File

@ -590,7 +590,7 @@ CXWindowsScreen::updateScreenShape()
m_y = 0; m_y = 0;
m_w = WidthOfScreen(DefaultScreenOfDisplay(m_display)); m_w = WidthOfScreen(DefaultScreenOfDisplay(m_display));
m_h = HeightOfScreen(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 // get center of default screen
m_xCenter = m_x + (m_w >> 1); m_xCenter = m_x + (m_w >> 1);