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

@@ -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: <unknown 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: <unknown error>"));
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;