projects
/
ghc-hetmet.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
87e82c1
)
protect console handler against concurrent access (#1922)
author
Simon Marlow
<simonmar@microsoft.com>
Tue, 4 Dec 2007 15:39:18 +0000
(15:39 +0000)
committer
Simon Marlow
<simonmar@microsoft.com>
Tue, 4 Dec 2007 15:39:18 +0000
(15:39 +0000)
rts/win32/ConsoleHandler.c
patch
|
blob
|
history
diff --git
a/rts/win32/ConsoleHandler.c
b/rts/win32/ConsoleHandler.c
index
a2de74b
..
76ebea0
100644
(file)
--- a/
rts/win32/ConsoleHandler.c
+++ b/
rts/win32/ConsoleHandler.c
@@
-264,8
+264,13
@@
rts_InstallConsoleEvent(int action, StgStablePtr *handler)
}
break;
case STG_SIG_HAN:
}
break;
case STG_SIG_HAN:
+#ifdef THREADED_RTS
+ // handler is stored in an MVar in the threaded RTS
+ console_handler = STG_SIG_HAN;
+#else
console_handler = (StgInt)*handler;
console_handler = (StgInt)*handler;
- if ( previous_hdlr < 0 ) {
+#endif
+ if (previous_hdlr < 0 || previous_hdlr == STG_SIG_HAN) {
/* Only install generic_handler() once */
if ( !SetConsoleCtrlHandler(generic_handler, TRUE) ) {
errorBelch("warning: unable to install console event handler");
/* Only install generic_handler() once */
if ( !SetConsoleCtrlHandler(generic_handler, TRUE) ) {
errorBelch("warning: unable to install console event handler");
@@
-275,10
+280,13
@@
rts_InstallConsoleEvent(int action, StgStablePtr *handler)
}
if (previous_hdlr == STG_SIG_DFL ||
}
if (previous_hdlr == STG_SIG_DFL ||
- previous_hdlr == STG_SIG_IGN) {
+ previous_hdlr == STG_SIG_IGN ||
+ previous_hdlr == STG_SIG_HAN) {
return previous_hdlr;
} else {
return previous_hdlr;
} else {
- *handler = (StgStablePtr)previous_hdlr;
+ if (handler != NULL) {
+ *handler = (StgStablePtr)previous_hdlr;
+ }
return STG_SIG_HAN;
}
}
return STG_SIG_HAN;
}
}