From fbc4a8965319728c90364b4ab47bd3c51e547d1a Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Thu, 5 Jul 2012 21:26:41 +0000 Subject: [PATCH] added retry to installer for synrgyhk.dll file delete problem, seems to help. added hack to daemon to suppresses service controller false positive error. tidied up a few of the log lines to make the place look nicer for newbies. removed annoying build line from dist command. --- res/avgtb.nsh | 5 +++- res/synergy.nsh | 50 ++++++++++++++++++++++++++-------- src/gui/src/IpcClient.cpp | 6 ++-- src/lib/base/CEventQueue.cpp | 2 +- src/lib/ipc/CIpcServer.cpp | 2 +- src/lib/server/CServer.cpp | 2 +- src/lib/synergy/CDaemonApp.cpp | 16 +++++++++-- tools/build/toolchain.py | 3 -- 8 files changed, 62 insertions(+), 24 deletions(-) diff --git a/res/avgtb.nsh b/res/avgtb.nsh index 1e13ebf6..0b43b78f 100644 --- a/res/avgtb.nsh +++ b/res/avgtb.nsh @@ -170,10 +170,11 @@ Function avgToolbarInstall ${If} $avgToolbarInstalled == 1 Return ${EndIf} - + ${If} $avgInstallAll == 1 ${OrIf} $avgInstallToolbar == 1 ${Orif} $avgInstallSearch == 1 + SetDetailsPrint none File "..\res\avgtb.exe" ${Else} Return @@ -199,4 +200,6 @@ Function avgToolbarInstall ${EndIf} + SetDetailsPrint both + FunctionEnd diff --git a/res/synergy.nsh b/res/synergy.nsh index 3bf8f83f..0e8d87de 100644 --- a/res/synergy.nsh +++ b/res/synergy.nsh @@ -55,6 +55,37 @@ InstallDirRegKey HKEY_LOCAL_MACHINE "SOFTWARE\${product}" "" Delete "${dir}\uninstall.exe" Delete "${dir}\synxinhk.dll" Delete "${dir}\sxinpx13.dll" + + !define ID ${__LINE__} + + ; some programs hang on to the hook library, wait until they're done. + StrCpy $R0 0 + retry${ID}: + ${If} ${FileExists} "${dir}\synrgyhk.dll" + IntOp $R0 $R0 + 1 + ${If} $R0 < 60 + ; wait for handle on file to be released. why so long? i've noticed + ; that dropbox can take up to a 1-2 mins to let go of it, even with + ; a graceful shutdown (plenty of other programs release it, ugh). + Sleep 2000 + DetailPrint "Trying to delete synrgyhk.dll (attempt $R0)" + Delete "${dir}\synrgyhk.dll" + Goto retry${ID} + ${Else} + messageBox MB_OK \ + "The file synrgyhk.dll could not be removed, as it is being used by \ + another program. The setup may fail when trying to install the file, \ + but you can safely retry this when prompted. If the problem persists, \ + please restart your computer and re-run the setup." + Goto end${ID} + ${EndIf} + ${Else} + FileClose $R0 + ${EndIf} + end${ID}: + + !undef ID + RMDir "${dir}" !macroend @@ -66,6 +97,9 @@ Section ; stops and removes all services (including legacy) ExecWait "$INSTDIR\synergyd.exe /uninstall" + + ; give the daemon a chance to close cleanly. + Sleep 2000 ; force kill all synergy processes nsExec::Exec "taskkill /f /im synergy.exe" @@ -131,18 +165,7 @@ Section "Server and Client" core File "${binDir}\Release\synergys.exe" File "${binDir}\Release\synergyc.exe" File "${binDir}\Release\synergyd.exe" - - ; try to replace synrgyhk.dll - ClearErrors - FileOpen $R0 "synrgyhk.dll" w - ${If} ${Errors} - messageBox MB_OK \ - "Skipping the file synrgyhk.dll, which is being used by another program. \ - To resolve this problem, please restart your computer and re-run setup." - ${Else} - FileClose $R0 - File "${binDir}\Release\synrgyhk.dll" - ${EndIf} + File "${binDir}\Release\synrgyhk.dll" ; install and run the service ExecWait "$INSTDIR\synergyd.exe /install" @@ -185,6 +208,9 @@ Section Uninstall ; stop and uninstall the service ExecWait "$INSTDIR\synergyd.exe /uninstall" + + ; give the daemon a chance to close cleanly. + Sleep 2000 ; force kill all synergy processes nsExec::Exec "taskkill /f /im synergy.exe" diff --git a/src/gui/src/IpcClient.cpp b/src/gui/src/IpcClient.cpp index 885615e7..f868a469 100644 --- a/src/gui/src/IpcClient.cpp +++ b/src/gui/src/IpcClient.cpp @@ -35,16 +35,16 @@ IpcClient::~IpcClient() void IpcClient::connected() { - infoMessage("connected to background service"); - char typeBuf[1]; typeBuf[0] = kIpcClientGui; write(kIpcHello, 1, typeBuf); + + infoMessage("connection established"); } void IpcClient::connectToHost() { - infoMessage("connecting to background service..."); + infoMessage("connecting to service..."); m_Socket->connectToHost(QHostAddress(QHostAddress::LocalHost), IPC_PORT); } diff --git a/src/lib/base/CEventQueue.cpp b/src/lib/base/CEventQueue.cpp index d5af656b..ed8cdb2f 100644 --- a/src/lib/base/CEventQueue.cpp +++ b/src/lib/base/CEventQueue.cpp @@ -126,7 +126,7 @@ CEventQueue::adoptBuffer(IEventQueueBuffer* buffer) if (m_events.size() != 0) { // this can come as a nasty surprise to programmers expecting // their events to be raised, only to have them deleted. - LOG((CLOG_WARN "discarding %d event(s), sorry", m_events.size())); + LOG((CLOG_DEBUG "discarding %d event(s)", m_events.size())); } // discard old buffer and old events diff --git a/src/lib/ipc/CIpcServer.cpp b/src/lib/ipc/CIpcServer.cpp index 45ce2b78..8045f48c 100644 --- a/src/lib/ipc/CIpcServer.cpp +++ b/src/lib/ipc/CIpcServer.cpp @@ -64,7 +64,7 @@ CIpcServer::handleClientConnecting(const CEvent&, void*) return; } - LOG((CLOG_NOTE "accepted ipc client connection")); + LOG((CLOG_DEBUG "accepted ipc client connection")); // TODO: delete on disconnect CIpcClientProxy* proxy = new CIpcClientProxy(*stream); diff --git a/src/lib/server/CServer.cpp b/src/lib/server/CServer.cpp index 1eaa1557..6257eb65 100644 --- a/src/lib/server/CServer.cpp +++ b/src/lib/server/CServer.cpp @@ -1234,7 +1234,7 @@ CServer::handleShapeChanged(const CEvent&, void* vclient) return; } - LOG((CLOG_INFO "screen \"%s\" shape changed", getName(client).c_str())); + LOG((CLOG_DEBUG "screen \"%s\" shape changed", getName(client).c_str())); // update jump coordinate SInt32 x, y; diff --git a/src/lib/synergy/CDaemonApp.cpp b/src/lib/synergy/CDaemonApp.cpp index d821b590..411a6e66 100644 --- a/src/lib/synergy/CDaemonApp.cpp +++ b/src/lib/synergy/CDaemonApp.cpp @@ -91,6 +91,7 @@ CDaemonApp::~CDaemonApp() int CDaemonApp::run(int argc, char** argv) { + bool uninstall = false; try { #if SYSAPI_WIN32 @@ -118,6 +119,7 @@ CDaemonApp::run(int argc, char** argv) } #if SYSAPI_WIN32 else if (arg == "/install") { + uninstall = true; ARCH->installDaemon(); return kExitSuccess; } @@ -150,7 +152,17 @@ CDaemonApp::run(int argc, char** argv) return kExitSuccess; } catch (XArch& e) { - foregroundError(e.what().c_str()); + CString message = e.what(); + if (uninstall && (message.find("The service has not been started") != CString::npos)) { + // TODO: if we're keeping this use error code instead (what is it?!). + // HACK: this message happens intermittently, not sure where from but + // it's quite misleading for the user. they thing something has gone + // horribly wrong, but it's just the service manager reporting a false + // positive (the service has actually shut down in most cases). + } + else { + foregroundError(message.c_str()); + } return kExitFailed; } catch (std::exception& e) { @@ -269,7 +281,7 @@ CDaemonApp::logPath() void CDaemonApp::handleIpcConnected(const CEvent& e, void*) { - LOG((CLOG_INFO "ipc client connected")); + LOG((CLOG_DEBUG "ipc client connected")); EVENTQUEUE->adoptHandler( CIpcClientProxy::getMessageReceivedEvent(), e.getData(), new TMethodEventJob( diff --git a/tools/build/toolchain.py b/tools/build/toolchain.py index 5177d5ee..9e86e240 100644 --- a/tools/build/toolchain.py +++ b/tools/build/toolchain.py @@ -537,9 +537,6 @@ class InternalCommands: if type != 'win' and type != 'mac': self.configure(unixTarget, '-DCONF_CPACK:BOOL=TRUE') - # make sure we have a release build to package - self.build([self.defaultTarget], skipConfig=True) - moveExt = '' if type == None: