diff --git a/src/io.cpp b/src/io.cpp index ccb2a05be..9a8bcc0b0 100644 --- a/src/io.cpp +++ b/src/io.cpp @@ -151,13 +151,16 @@ void io_buffer_t::begin_filling(autoclose_fd_t fd) { promise->set_value(); } }; - fd_monitor().add(std::move(item)); + this->item_id_ = fd_monitor().add(std::move(item)); } void io_buffer_t::complete_background_fillthread() { + // Mark that our fillthread is done, then wake it up. ASSERT_IS_MAIN_THREAD(); assert(fillthread_running() && "Should have a fillthread"); + assert(this->item_id_ > 0 && "Should have a valid item ID"); shutdown_fillthread_ = true; + fd_monitor().poke_item(this->item_id_); // Wait for the fillthread to fulfill its promise, and then clear the future so we know we no // longer have one. diff --git a/src/io.h b/src/io.h index a1c9417cd..702954cf6 100644 --- a/src/io.h +++ b/src/io.h @@ -312,6 +312,9 @@ class io_buffer_t { /// running. The fillthread fulfills the corresponding promise when it exits. std::future fillthread_waiter_{}; + /// The item id of our background fillthread fd monitor item. + uint64_t item_id_{0}; + /// Lock for appending. std::mutex append_lock_{};