[llvm-commits] CVS: llvm/lib/System/Win32/Signals.cpp
Reid Spencer
reid at x10sys.com
Thu Sep 16 20:02:38 PDT 2004
Changes in directory llvm/lib/System/Win32:
Signals.cpp updated: 1.2 -> 1.3
---
Log message:
Make sure critical sections are entered before trying to leave them.
Add some additional commentary about the workings of this module.
Patch contributed by Jeff Cohen. Thanks Jeff!
---
Diffs of the changes: (+12 -1)
Index: llvm/lib/System/Win32/Signals.cpp
diff -u llvm/lib/System/Win32/Signals.cpp:1.2 llvm/lib/System/Win32/Signals.cpp:1.3
--- llvm/lib/System/Win32/Signals.cpp:1.2 Thu Sep 16 10:53:16 2004
+++ llvm/lib/System/Win32/Signals.cpp Thu Sep 16 22:02:27 2004
@@ -28,6 +28,10 @@
static std::vector<std::string> *FilesToRemove = NULL;
static std::vector<llvm::sys::Path> *DirectoriesToRemove = NULL;
static bool RegisteredUnhandledExceptionFilter = false;
+
+// Windows creates a new thread to execute the console handler when an event
+// (such as CTRL/C) occurs. This causes concurrency issues with the above
+// globals which this critical section addresses.
static CRITICAL_SECTION CriticalSection;
namespace llvm {
@@ -40,7 +44,10 @@
static void RegisterHandler() {
if (RegisteredUnhandledExceptionFilter)
+ {
+ EnterCriticalSection(&CriticalSection);
return;
+ }
// Now's the time to create the critical section. This is the first time
// through here, and there's only one thread.
@@ -205,9 +212,13 @@
}
static BOOL WINAPI LLVMConsoleCtrlHandler(DWORD dwCtrlType) {
+ // FIXME: This handler executes on a different thread. The main thread
+ // is still running, potentially creating new files to be cleaned up
+ // in the tiny window between the call to Cleanup() and process termination.
+ // Also, any files currently open cannot be deleted.
Cleanup();
- // Allow normal processing to take place.
+ // Allow normal processing to take place; i.e., the process dies.
return FALSE;
}
More information about the llvm-commits
mailing list