summaryrefslogtreecommitdiff
path: root/includes/rts/EventLogWriter.h
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2020-05-21 11:53:35 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-05-27 00:14:33 -0400
commit04750304deae2128a8350e28224e1f62ae949820 (patch)
tree2b2f402defb7aa7ede3a75dc05b724b32adc381f /includes/rts/EventLogWriter.h
parentede241268171e8eee1e750d88ff356ddbfc357f2 (diff)
downloadhaskell-04750304deae2128a8350e28224e1f62ae949820.tar.gz
eventlog: Fix racy flushing
Previously no attempt was made to avoid multiple threads writing their capability-local eventlog buffers to the eventlog writer simultaneously. This could result in multiple eventlog streams being interleaved. Fix this by documenting that the EventLogWriter's write() and flush() functions may be called reentrantly and fix the default writer to protect its FILE* by a mutex. Fixes #18210.
Diffstat (limited to 'includes/rts/EventLogWriter.h')
-rw-r--r--includes/rts/EventLogWriter.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/includes/rts/EventLogWriter.h b/includes/rts/EventLogWriter.h
index 4975b72b07..38a0c06086 100644
--- a/includes/rts/EventLogWriter.h
+++ b/includes/rts/EventLogWriter.h
@@ -24,9 +24,13 @@ typedef struct {
void (* initEventLogWriter) (void);
// Write a series of events returning true on success.
+ // Note that this may be called by multiple threads simultaneously.
+ // The writer is responsible for concurrency control.
bool (* writeEventLog) (void *eventlog, size_t eventlog_size);
// Flush possibly existing buffers (may be NULL)
+ // Note that this may be called by multiple threads simultaneously.
+ // The writer is responsible for concurrency control.
void (* flushEventLog) (void);
// Close an initialized EventLogOutput (may be NULL)