Adds an `emplace()` method to RunOnExit, and deletes the move and copy constructors.
There's some evidence in CL 411404964 that the copy constructor is accidentally used in the ChromeOS Chromium build.
PiperOrigin-RevId: 411618225
diff --git a/http2/adapter/oghttp2_adapter_test.cc b/http2/adapter/oghttp2_adapter_test.cc
index 7d0ca8a..c3f4356 100644
--- a/http2/adapter/oghttp2_adapter_test.cc
+++ b/http2/adapter/oghttp2_adapter_test.cc
@@ -1836,7 +1836,7 @@
}
TEST(OgHttp2AdapterServerTest,
- DISABLED_IncompleteRequestWithServerResponseRstStreamEnabled) {
+ IncompleteRequestWithServerResponseRstStreamEnabled) {
DataSavingVisitor visitor;
OgHttp2Adapter::Options options{.perspective = Perspective::kServer,
.rst_stream_no_error_when_incomplete = true};
diff --git a/http2/adapter/oghttp2_session.cc b/http2/adapter/oghttp2_session.cc
index 168a9a0..0792a5c 100644
--- a/http2/adapter/oghttp2_session.cc
+++ b/http2/adapter/oghttp2_session.cc
@@ -127,8 +127,10 @@
RunOnExit() = default;
explicit RunOnExit(std::function<void()> f) : f_(std::move(f)) {}
- RunOnExit(RunOnExit&& other) = default;
- RunOnExit& operator=(RunOnExit&& other) = default;
+ RunOnExit(const RunOnExit& other) = delete;
+ RunOnExit& operator=(const RunOnExit& other) = delete;
+ RunOnExit(RunOnExit&& other) = delete;
+ RunOnExit& operator=(RunOnExit&& other) = delete;
~RunOnExit() {
if (f_) {
@@ -137,6 +139,8 @@
f_ = {};
}
+ void emplace(std::function<void()> f) { f_ = std::move(f); }
+
private:
std::function<void()> f_;
};
@@ -417,7 +421,7 @@
streams_reset_.insert(frame->stream_id());
} else if (iter != stream_map_.end()) {
// Enqueue RST_STREAM NO_ERROR if appropriate.
- r = RunOnExit{[this, iter]() { MaybeFinWithRstStream(iter); }};
+ r.emplace([this, iter]() { MaybeFinWithRstStream(iter); });
}
}
if (frame->stream_id() != 0) {