fixed problem with opening client and server. in some cases it

would fail to open in such a way that it could never succeed
but it'd never stop retrying.  now terminating when open fails
such that it'll never succeed.
This commit is contained in:
crs
2002-07-31 12:39:34 +00:00
parent f5795a6630
commit 5e40de48f9
18 changed files with 141 additions and 59 deletions

View File

@@ -43,7 +43,7 @@ public:
//@}
// IClient overrides
virtual bool open() = 0;
virtual void open() = 0;
virtual void mainLoop() = 0;
virtual void close() = 0;
virtual void enter(SInt32 xAbs, SInt32 yAbs,

View File

@@ -29,7 +29,7 @@ CClientProxy1_0::~CClientProxy1_0()
// do nothing
}
bool
void
CClientProxy1_0::open()
{
// send request
@@ -55,8 +55,6 @@ CClientProxy1_0::open()
// handle reply
recvInfo(false);
return true;
}
void

View File

@@ -14,7 +14,7 @@ public:
~CClientProxy1_0();
// IClient overrides
virtual bool open();
virtual void open();
virtual void mainLoop();
virtual void close();
virtual void enter(SInt32 xAbs, SInt32 yAbs,

View File

@@ -399,6 +399,7 @@ CMSWindowsPrimaryScreen::onPreOpen()
// initialize hook library
m_threadID = GetCurrentThreadId();
if (m_init(m_threadID) == 0) {
log((CLOG_ERR "cannot initialize hook library"));
throw XScreenOpenFailure();
}
}

View File

@@ -1,6 +1,7 @@
#include "CPrimaryClient.h"
#include "IPrimaryScreenFactory.h"
#include "IServer.h"
#include "XScreen.h"
#include "XSynergy.h"
#include "CPrimaryScreen.h"
#include "CClipboard.h"
@@ -19,11 +20,15 @@ CPrimaryClient::CPrimaryClient(IPrimaryScreenFactory* screenFactory,
m_seqNum(0)
{
assert(m_server != NULL);
assert(screenFactory != NULL);
// create screen
log((CLOG_DEBUG1 "creating primary screen"));
m_screen = screenFactory->create(this, receiver);
if (screenFactory != NULL) {
m_screen = screenFactory->create(this, receiver);
}
if (m_screen == NULL) {
throw XScreenOpenFailure();
}
}
CPrimaryClient::~CPrimaryClient()
@@ -100,7 +105,7 @@ CPrimaryClient::onClipboardChanged(ClipboardID id, const CString& data)
m_server->onClipboardChanged(id, m_seqNum, data);
}
bool
void
CPrimaryClient::open()
{
// all clipboards are clean
@@ -110,8 +115,6 @@ CPrimaryClient::open()
// now open the screen
m_screen->open();
return true;
}
void

View File

@@ -20,8 +20,9 @@ treated as if it was on a client.
class CPrimaryClient : public IScreenReceiver, public IClient {
public:
/*!
\c name is the name of the server. the caller retains ownership of
\c factory.
\c name is the name of the server. The caller retains ownership of
\c factory. Throws XScreenOpenFailure or whatever the factory can
throw if the screen cannot be created.
*/
CPrimaryClient(IPrimaryScreenFactory* factory, IServer*,
IPrimaryScreenReceiver*, const CString& name);
@@ -75,7 +76,7 @@ public:
virtual void onClipboardChanged(ClipboardID, const CString&);
// IClient overrides
virtual bool open();
virtual void open();
virtual void mainLoop();
virtual void close();
virtual void enter(SInt32 xAbs, SInt32 yAbs,

View File

@@ -53,24 +53,23 @@ CServer::~CServer()
delete m_streamFilterFactory;
}
bool
void
CServer::open()
{
// open the screen
try {
log((CLOG_INFO "opening screen"));
openPrimaryScreen();
return true;
}
catch (XScreenOpenFailure&) {
// can't open screen yet. wait a few seconds to retry.
catch (XScreen&) {
// can't open screen
log((CLOG_INFO "failed to open screen"));
return false;
throw;
}
catch (XUnknownClient& e) {
// can't open screen yet. wait a few seconds to retry.
// can't open screen
log((CLOG_CRIT "unknown screen name `%s'", e.getName().c_str()));
return false;
throw;
}
}
@@ -1529,7 +1528,6 @@ void
CServer::openPrimaryScreen()
{
assert(m_primaryClient == NULL);
assert(m_screenFactory != NULL);
// reset sequence number
m_seqNum = 0;

View File

@@ -39,9 +39,12 @@ public:
//! Open server
/*!
Open the server and return true iff successful.
Open the server. Throws XScreenUnavailable if the server's
screen cannot be opened but might be available after some time.
Otherwise throws some other exception if the server's screen or
the server cannot be opened and retrying won't help.
*/
bool open();
void open();
//! Server main loop
/*!