Skip to content

Commit d5d04dc

Browse files
committed
istream/ThreadIstream: avoid unlocked drained read after reschedule
Internal::Done() may reschedule a new worker run before evaluating the EOF/disposal condition. That condition read drained without holding mutex, even though the new worker run can update drained under the mutex concurrently. Reorder the short-circuit condition so _again is tested first. This avoids touching drained on the rescheduled path and removes the data race without changing the state machine.
1 parent ffd3051 commit d5d04dc

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/istream/ThreadIstream.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ ThreadIstream::Internal::Done() noexcept
237237
auto &_istream = istream;
238238

239239
bool destroyed = false;
240-
if (!has_input && input_empty && drained && !_again) {
240+
if (!_again && !has_input && input_empty && drained) {
241241
/* there is no more input and the filter's output
242242
buffers are drained: we don't need it anymore, we
243243
already have all we need */

0 commit comments

Comments
 (0)