Browse Source

Fix zombie plCrashHandler issues

Win32 HACK: We wait on both the pfCrashCli handle and the crashed semaphore.
This way, we can proceed to exit pfCrashSrv when the client process exits
insanely.
Adam Johnson 12 years ago
parent
commit
151657a9f2
  1. 14
      Sources/Plasma/CoreLib/hsThread.h
  2. 15
      Sources/Plasma/FeatureLib/pfCrashHandler/plCrashSrv.cpp

14
Sources/Plasma/CoreLib/hsThread.h

@ -115,7 +115,11 @@ class hsMutex {
public:
hsMutex();
virtual ~hsMutex();
#ifdef HS_BUILD_FOR_WIN32
HANDLE GetHandle() const { return fMutexH; }
#endif
void Lock();
hsBool TryLock();
void Unlock();
@ -157,6 +161,10 @@ public:
hsSemaphore(int initialValue=0, const char* name=nil);
~hsSemaphore();
#ifdef HS_BUILD_FOR_WIN32
HANDLE GetHandle() const { return fSemaH; }
#endif
hsBool TryWait();
hsBool Wait(hsMilliseconds timeToWait = kPosInfinity32);
void Signal();
@ -183,6 +191,10 @@ public:
hsEvent();
~hsEvent();
#ifdef HS_BUILD_FOR_WIN32
HANDLE GetHandle() const { return fEvent; }
#endif
hsBool Wait(hsMilliseconds timeToWait = kPosInfinity32);
void Signal();
};

15
Sources/Plasma/FeatureLib/pfCrashHandler/plCrashSrv.cpp

@ -108,10 +108,21 @@ void plCrashSrv::IHandleCrash()
void plCrashSrv::HandleCrash()
{
fCrashed->Wait(); // Wait for a crash
#ifdef HS_BUILD_FOR_WIN32
if (!fLink)
FATAL("plCrashMemLink is nil!");
// In Win32 land we have to hackily handle the client process exiting, so we'll wait on both
// the crashed semaphore and the client process...
HANDLE hack[2] = { fLink->fClientProcess, fCrashed->GetHandle() };
DWORD result = WaitForMultipleObjects(arrsize(hack), hack, FALSE, INFINITE);
hsAssert(result != WAIT_FAILED, "WaitForMultipleObjects failed");
#else
fCrashed->Wait();
if (!fLink)
FATAL("plCrashMemLink is nil!");
else if (fLink->fCrashed)
#endif
if (fLink->fCrashed)
IHandleCrash();
fHandled->Signal(); // Tell CrashCli we handled it
}

Loading…
Cancel
Save