File tree Expand file tree Collapse file tree
google/cloud/storage/internal/async Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -108,8 +108,10 @@ ObjectDescriptorImpl::Read(ReadParams p) {
108108}
109109
110110void ObjectDescriptorImpl::Flush (std::unique_lock<std::mutex> lk) {
111- if (write_pending_ || next_request_.read_ranges ().empty ()) return ;
112- write_pending_ = true ;
111+ if (streams_.back ().write_pending || next_request_.read_ranges ().empty ()) {
112+ return ;
113+ }
114+ streams_.back ().write_pending = true ;
113115 google::storage::v2::BidiReadObjectRequest request;
114116 request.Swap (&next_request_);
115117
@@ -125,7 +127,7 @@ void ObjectDescriptorImpl::Flush(std::unique_lock<std::mutex> lk) {
125127void ObjectDescriptorImpl::OnWrite (bool ok) {
126128 std::unique_lock<std::mutex> lk (mu_);
127129 if (!ok) return DoFinish (std::move (lk));
128- write_pending_ = false ;
130+ streams_. back (). write_pending = false ;
129131 Flush (std::move (lk));
130132}
131133
@@ -215,7 +217,7 @@ void ObjectDescriptorImpl::Resume(google::rpc::Status const& proto_status) {
215217 if (!range) continue ;
216218 *request.add_read_ranges () = *std::move (range);
217219 }
218- write_pending_ = true ;
220+ streams_. back (). write_pending = true ;
219221 lk.unlock ();
220222 make_stream_ (std::move (request)).then ([w = WeakFromThis ()](auto f) {
221223 if (auto self = w.lock ()) self->OnResume (f.get ());
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ class ObjectDescriptorImpl
4343 std::shared_ptr<OpenStream> stream;
4444 std::unordered_map<std::int64_t , std::shared_ptr<ReadRange>> active_ranges;
4545 std::unique_ptr<storage_experimental::ResumePolicy> resume_policy;
46+ bool write_pending = false ;
4647 };
4748
4849 public:
@@ -110,7 +111,6 @@ class ObjectDescriptorImpl
110111 google::storage::v2::BidiReadObjectSpec read_object_spec_;
111112 absl::optional<google::storage::v2::Object> metadata_;
112113 std::int64_t read_id_generator_ = 0 ;
113- bool write_pending_ = false ;
114114 google::storage::v2::BidiReadObjectRequest next_request_;
115115
116116 Options options_;
You can’t perform that action at this time.
0 commit comments