Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make http client restart requests #1883

Closed
wants to merge 9 commits into from
20 changes: 14 additions & 6 deletions tests/unit/loopback_socket.hh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private:
queue<temporary_buffer<char>> _q{1};
loopback_error_injector* _error_injector;
type _type;
promise<> _shutdown;
std::optional<promise<>> _shutdown;
public:
loopback_buffer(loopback_error_injector* error_injection, type t) : _error_injector(error_injection), _type(t) {}
future<> push(temporary_buffer<char>&& b) {
Expand Down Expand Up @@ -92,16 +92,22 @@ public:
return _q.pop_eventually();
}
void abort() noexcept {
nyh marked this conversation as resolved.
Show resolved Hide resolved
if (!_aborted) {
// it can be called by both -- reader and writer socket impls
_shutdown.set_value();
}
shutdown();
_aborted = true;
_q.abort(std::make_exception_ptr(std::system_error(EPIPE, std::system_category())));
}
void shutdown() noexcept {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got lost here. You renamed the old shutdown() to abort, and now you're re-introducing shutdown()? Or maybe it's a different overload with the same name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, yes, I'm introducing another shutdown(). Old shutdown (that got renamed to abort) now calls new shutdown and aborts the inner queue

// it can be called by both -- reader and writer socket impls
if (_shutdown.has_value()) {
_shutdown->set_value();
_shutdown.reset();
}
}

future<> wait_input_shutdown() {
return _shutdown.get_future();
assert(!_shutdown.has_value());
nyh marked this conversation as resolved.
Show resolved Hide resolved
_shutdown.emplace();
return _shutdown->get_future();
}
};

Expand Down Expand Up @@ -160,6 +166,8 @@ public:
future<> close() override {
if (!_eof) {
_buffer->abort();
} else {
_buffer->shutdown();
}
return make_ready_future<>();
}
Expand Down