Skip to content

Commit

Permalink
Make sure future is accessed in a thread-safe way.
Browse files Browse the repository at this point in the history
  • Loading branch information
pitrou committed Jun 10, 2024
1 parent 54463ca commit c48d59a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cpp/src/arrow/filesystem/s3fs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1898,8 +1898,13 @@ class ObjectOutputStream final : public io::OutputStream {
if (--state->parts_in_progress == 0) {
// GH-41862: avoid potential deadlock if the Future's callback is called
// with the mutex taken.
auto fut = state->pending_parts_completed;
lock.unlock();
state->pending_parts_completed.MarkFinished(state->status);
// State could be mutated concurrently if another thread writes to the
// stream, but in this case the Flush() call is only advisory anyway.
// Besides, it's not generally sound to write to an OutputStream from
// several threads at once.
fut.MarkFinished(state->status);
}
}

Expand Down

0 comments on commit c48d59a

Please sign in to comment.