Restarted process from GUI in desktop mode #4901

This commit is contained in:
Xinyu Hou 2015-07-29 02:01:39 +01:00 committed by Jerry (Xinyu Hou)
parent 86d5567e74
commit fc600efdfe
3 changed files with 128 additions and 2 deletions

96
1.patch Normal file
View File

@ -0,0 +1,96 @@
diff --git a/src/lib/plugin/ns/SecureSocket.cpp b/src/lib/plugin/ns/SecureSocket.cpp
index 40c3f21..e02ba9d 100644
--- a/src/lib/plugin/ns/SecureSocket.cpp
+++ b/src/lib/plugin/ns/SecureSocket.cpp
@@ -35,12 +35,9 @@
//
#define MAX_ERROR_SIZE 65535
-
-enum {
- // this limit seems extremely high, but mac client seem to generate around
- // 50,000 errors before they establish a connection (wtf?)
- kMaxRetryCount = 100000
-};
+// RETRY_DELAY * MAX_RETRY = 10s
+#define MAX_RETRY 1000
+#define RETRY_DELAY 0.01f
enum {
kMsgSize = 128
@@ -61,8 +58,7 @@ SecureSocket::SecureSocket(
SocketMultiplexer* socketMultiplexer) :
TCPSocket(events, socketMultiplexer),
m_secureReady(false),
- m_fatal(false),
- m_maxRetry(kMaxRetryCount)
+ m_fatal(false)
{
}
@@ -72,8 +68,7 @@ SecureSocket::SecureSocket(
ArchSocket socket) :
TCPSocket(events, socketMultiplexer, socket),
m_secureReady(false),
- m_fatal(false),
- m_maxRetry(kMaxRetryCount)
+ m_fatal(false)
{
}
@@ -295,8 +290,7 @@ SecureSocket::secureAccept(int socket)
if (isFatal()) {
// tell user and sleep so the socket isn't hammered.
- LOG((CLOG_ERR "failed to accept secure socket"));
- LOG((CLOG_INFO "client connection may not be secure"));
+ LOG((CLOG_WARN "failed to accept secure socket"));
m_secureReady = false;
ARCH->sleep(1);
retry = 0;
@@ -318,6 +312,7 @@ SecureSocket::secureAccept(int socket)
if (retry > 0) {
LOG((CLOG_DEBUG2 "retry accepting secure socket"));
m_secureReady = false;
+ ARCH->sleep(RETRY_DELAY);
return 0;
}
@@ -351,6 +346,7 @@ SecureSocket::secureConnect(int socket)
if (retry > 0) {
LOG((CLOG_DEBUG2 "retry connect secure socket"));
m_secureReady = false;
+ ARCH->sleep(RETRY_DELAY);
return 0;
}
@@ -475,8 +471,8 @@ SecureSocket::checkResult(int status, int& retry)
}
// If the retry max would exceed the allowed, treat it as a fatal error
- if (retry > maxRetry()) {
- LOG((CLOG_ERR "passive ssl error limit exceeded: %d", retry));
+ if (retry > MAX_RETRY) {
+ LOG((CLOG_DEBUG "retry exceeded %d sec", RETRY_DELAY * MAX_RETRY));
isFatal(true);
}
diff --git a/src/lib/plugin/ns/SecureSocket.h b/src/lib/plugin/ns/SecureSocket.h
index 0c0f3b1..871e1e4 100644
--- a/src/lib/plugin/ns/SecureSocket.h
+++ b/src/lib/plugin/ns/SecureSocket.h
@@ -52,8 +52,6 @@ public:
int secureWrite(const void* buffer, int size, int& wrote);
void initSsl(bool server);
bool loadCertificates(String& CertFile);
- void maxRetry(int limit) { m_maxRetry = limit; };
- int maxRetry() const { return m_maxRetry; };
private:
// SSL
@@ -87,5 +85,4 @@ private:
Ssl* m_ssl;
bool m_secureReady;
bool m_fatal;
- int m_maxRetry;
};

View File

@ -96,7 +96,8 @@ MainWindow::MainWindow(QSettings& settings, AppConfig& appConfig) :
m_pCancelButton(NULL), m_pCancelButton(NULL),
m_SuppressAutoConfigWarning(false), m_SuppressAutoConfigWarning(false),
m_BonjourInstall(NULL), m_BonjourInstall(NULL),
m_SuppressEmptyServerWarning(false) m_SuppressEmptyServerWarning(false),
m_ExpectedRunningState(kStopped)
{ {
setupUi(this); setupUi(this);
@ -142,6 +143,7 @@ MainWindow::MainWindow(QSettings& settings, AppConfig& appConfig) :
MainWindow::~MainWindow() MainWindow::~MainWindow()
{ {
if (appConfig().processMode() == Desktop) { if (appConfig().processMode() == Desktop) {
m_ExpectedRunningState = kStopped;
stopDesktop(); stopDesktop();
} }
@ -777,6 +779,15 @@ void MainWindow::synergyFinished(int exitCode, QProcess::ExitStatus)
QMessageBox::critical(this, tr("Synergy terminated with an error"), QString(tr("Synergy terminated unexpectedly with an exit code of %1.<br><br>Please see the log output for details.")).arg(exitCode)); QMessageBox::critical(this, tr("Synergy terminated with an error"), QString(tr("Synergy terminated unexpectedly with an exit code of %1.<br><br>Please see the log output for details.")).arg(exitCode));
stopSynergy(); stopSynergy();
} }
if (appConfig().processMode() == Desktop) {
if (m_ExpectedRunningState == kStarted) {
stopSynergy();
delay(1);
startSynergy();
}
}
#else #else
Q_UNUSED(exitCode); Q_UNUSED(exitCode);
#endif #endif
@ -823,6 +834,7 @@ void MainWindow::setSynergyState(qSynergyState state)
} }
setStatus(tr("Synergy is running.")); setStatus(tr("Synergy is running."));
m_ExpectedRunningState = kStarted;
break; break;
} }
@ -1338,3 +1350,14 @@ void MainWindow::delay(unsigned int s)
QCoreApplication::processEvents(QEventLoop::AllEvents, 100); QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
} }
} }
void MainWindow::on_m_pButtonToggleStart_clicked()
{
if (m_SynergyState != synergyConnected) {
m_ExpectedRunningState = kStarted;
}
else {
m_ExpectedRunningState = kStopped;
}
}

View File

@ -85,6 +85,11 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase
Info Info
}; };
enum qRuningState {
kStarted,
kStopped
};
public: public:
MainWindow(QSettings& settings, AppConfig& appConfig); MainWindow(QSettings& settings, AppConfig& appConfig);
~MainWindow(); ~MainWindow();
@ -138,7 +143,7 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase
protected: protected:
QSettings& settings() { return m_Settings; } QSettings& settings() { return m_Settings; }
AppConfig& appConfig() { return m_AppConfig; } AppConfig& appConfig() { return m_AppConfig; }
QProcess*& synergyProcess() { return m_pSynergy; } QProcess* synergyProcess() { return m_pSynergy; }
void setSynergyProcess(QProcess* p) { m_pSynergy = p; } void setSynergyProcess(QProcess* p) { m_pSynergy = p; }
void initConnections(); void initConnections();
void createMenuBar(); void createMenuBar();
@ -200,12 +205,14 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase
bool m_SuppressAutoConfigWarning; bool m_SuppressAutoConfigWarning;
CommandProcess* m_BonjourInstall; CommandProcess* m_BonjourInstall;
bool m_SuppressEmptyServerWarning; bool m_SuppressEmptyServerWarning;
qRuningState m_ExpectedRunningState;
private slots: private slots:
void on_m_pCheckBoxAutoConfig_toggled(bool checked); void on_m_pCheckBoxAutoConfig_toggled(bool checked);
void on_m_pComboServerList_currentIndexChanged(QString ); void on_m_pComboServerList_currentIndexChanged(QString );
void on_m_pButtonApply_clicked(); void on_m_pButtonApply_clicked();
void installBonjour(); void installBonjour();
void on_m_pButtonToggleStart_clicked();
}; };
#endif #endif