Unable to start synergy server with "Cannot create a file when that file already exists" message #3752
Go to next iteration as soon as it fails.
This commit is contained in:
parent
4a24a2117a
commit
bc772f98a6
|
@ -21,7 +21,6 @@
|
||||||
#include "synergy/XSynergy.h"
|
#include "synergy/XSynergy.h"
|
||||||
#include "base/Log.h"
|
#include "base/Log.h"
|
||||||
|
|
||||||
#include <Tlhelp32.h>
|
|
||||||
#include <Wtsapi32.h>
|
#include <Wtsapi32.h>
|
||||||
|
|
||||||
CMSWindowsSession::CMSWindowsSession() :
|
CMSWindowsSession::CMSWindowsSession() :
|
||||||
|
@ -72,6 +71,8 @@ CMSWindowsSession::isProcessInSession(const char* name, PHANDLE process = NULL)
|
||||||
// if we can not acquire session associated with a specified process,
|
// if we can not acquire session associated with a specified process,
|
||||||
// simply ignore it
|
// simply ignore it
|
||||||
LOG((CLOG_ERR "could not get session id for process id %i", entry.th32ProcessID));
|
LOG((CLOG_ERR "could not get session id for process id %i", entry.th32ProcessID));
|
||||||
|
gotEntry = nextProcessEntry(snapshot, &entry);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// only pay attention to processes in the active session
|
// only pay attention to processes in the active session
|
||||||
|
@ -89,17 +90,7 @@ CMSWindowsSession::isProcessInSession(const char* name, PHANDLE process = NULL)
|
||||||
}
|
}
|
||||||
|
|
||||||
// now move on to the next entry (if we're not at the end)
|
// now move on to the next entry (if we're not at the end)
|
||||||
gotEntry = Process32Next(snapshot, &entry);
|
gotEntry = nextProcessEntry(snapshot, &entry);
|
||||||
if (!gotEntry) {
|
|
||||||
|
|
||||||
DWORD err = GetLastError();
|
|
||||||
if (err != ERROR_NO_MORE_FILES) {
|
|
||||||
|
|
||||||
// only worry about error if it's not the end of the snapshot
|
|
||||||
LOG((CLOG_ERR "could not get next process entry"));
|
|
||||||
throw XArch(new XArchEvalWindows());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string nameListJoin;
|
std::string nameListJoin;
|
||||||
|
@ -161,3 +152,22 @@ CMSWindowsSession::updateActiveSession()
|
||||||
{
|
{
|
||||||
m_activeSessionId = WTSGetActiveConsoleSessionId();
|
m_activeSessionId = WTSGetActiveConsoleSessionId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOL
|
||||||
|
CMSWindowsSession::nextProcessEntry(HANDLE snapshot, LPPROCESSENTRY32 entry)
|
||||||
|
{
|
||||||
|
BOOL gotEntry = Process32Next(snapshot, entry);
|
||||||
|
if (!gotEntry) {
|
||||||
|
|
||||||
|
DWORD err = GetLastError();
|
||||||
|
if (err != ERROR_NO_MORE_FILES) {
|
||||||
|
|
||||||
|
// only worry about error if it's not the end of the snapshot
|
||||||
|
LOG((CLOG_ERR "could not get next process entry"));
|
||||||
|
throw XArch(new XArchEvalWindows());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return gotEntry;
|
||||||
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
#include <Tlhelp32.h>
|
||||||
|
|
||||||
class CMSWindowsSession {
|
class CMSWindowsSession {
|
||||||
public:
|
public:
|
||||||
|
@ -39,6 +40,9 @@ public:
|
||||||
|
|
||||||
void updateActiveSession();
|
void updateActiveSession();
|
||||||
|
|
||||||
|
private:
|
||||||
|
BOOL nextProcessEntry(HANDLE snapshot, LPPROCESSENTRY32 entry);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DWORD m_activeSessionId;
|
DWORD m_activeSessionId;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue