added better handling of X server disconnecting unexpectedly.

the apps still exit but they do it in a mostly controlled
manner.  in particular, the server threads except the one
processing primary screen events will terminate gracefully.
this will be important should the server ever allow HTTP
clients to rewrite the configuration file.

note that X makes it effectively impossible to continue once
the X server disconnects.  even if it didn't it would be
difficult for synergy to recover.  users will have to add
synergy to the X display manager's startup script if they
expect the server to be restarted.  alternatively, we could
add code to fork synergy at startup;  the child would do
the normal work while the parent would simply wait for the
child to exit and restart it.
This commit is contained in:
crs
2002-06-03 13:45:30 +00:00
parent ddbb465540
commit 1cbdaee31b
13 changed files with 242 additions and 70 deletions

View File

@@ -10,6 +10,7 @@
#include "CThread.h"
#include "CTimerThread.h"
#include "TMethodJob.h"
#include "XScreen.h"
#include "XSynergy.h"
#include "XThread.h"
#include <assert.h>
@@ -51,7 +52,16 @@ void CClient::run(const CNetworkAddress& serverAddress)
log((CLOG_NOTE "starting client"));
// connect to secondary screen
openSecondaryScreen();
while (m_screen == NULL) {
try {
openSecondaryScreen();
}
catch (XScreenOpenFailure&) {
// can't open screen yet. wait a few seconds to retry.
log((CLOG_INFO "failed to open screen. waiting to retry."));
CThread::sleep(3.0);
}
}
// start server interactions
m_serverAddress = &serverAddress;
@@ -88,7 +98,9 @@ void CClient::run(const CNetworkAddress& serverAddress)
thread->wait();
delete thread;
}
closeSecondaryScreen();
if (m_screen != NULL) {
closeSecondaryScreen();
}
throw;
}
catch (...) {
@@ -101,7 +113,9 @@ void CClient::run(const CNetworkAddress& serverAddress)
thread->wait();
delete thread;
}
closeSecondaryScreen();
if (m_screen != NULL) {
closeSecondaryScreen();
}
throw;
}
}