Commit 77230ec
[AsyncFileHandler] insure good synchronization for 'fRecordBuffer'
This field is accessed by various threads, whenever logging is
happening. All accesses are synchronized except the empty check
in timer thread, done before calling flush().
Once in a while, the record buffer is flushed to the writer queue
and a new, empty buffer is created and assigned to "fRecordBuffer".
If that happens just before the timer task does its empty check,
that thread might still see the old buffer, and then the call to
flush() might result in adding an empty buffer to the queue. To
avoid that, the empty check has been moved inside the synchronized
flush() function.
Also, for explicitness sake, mark field fFileHandler as final.
It's already used as such, and is only set in the constructor,
but this makes it explicit.
Signed-off-by: Marc Dumais <[email protected]>1 parent 85839ff commit 77230ec
File tree
1 file changed
+6
-6
lines changed- src/main/java/org/eclipse/tracecompass/traceeventlogger
1 file changed
+6
-6
lines changedLines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
| 90 | + | |
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | | - | |
109 | | - | |
110 | | - | |
| 108 | + | |
111 | 109 | | |
112 | 110 | | |
113 | 111 | | |
| |||
290 | 288 | | |
291 | 289 | | |
292 | 290 | | |
293 | | - | |
294 | | - | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
295 | 295 | | |
296 | 296 | | |
297 | 297 | | |
| |||
0 commit comments