Skip to content

Commit e8d3a71

Browse files
committed
testing out a hack
1 parent 17e83ba commit e8d3a71

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

libs/server-sent-events/src/client.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,7 @@ class FoxyClient : public Client,
292292
// if we're shutting down, so shutting_down_ is needed to
293293
// disambiguate.
294294
if (shutting_down_) {
295-
session_->opts.timeout = kShutdownTimeout;
296-
297-
return session_->async_shutdown(beast::bind_front_handler(
298-
&FoxyClient::on_shutdown, shared_from_this(), []() {}));
295+
return;
299296
}
300297
errors_(Error::ReadTimeout);
301298
return async_backoff(
@@ -348,6 +345,7 @@ class FoxyClient : public Client,
348345
std::move(completion)));
349346
}
350347

348+
void on_shutdown_write() { std::cout << "shutdown write completed\n"; }
351349
void do_shutdown(std::function<void()> completion) {
352350
std::cout << "shutdown request executing..\n";
353351
shutting_down_ = true;
@@ -357,6 +355,15 @@ class FoxyClient : public Client,
357355
} else {
358356
session_->stream.plain().cancel();
359357
}
358+
session_->opts.timeout = kShutdownTimeout;
359+
session_->async_shutdown(beast::bind_front_handler(
360+
&FoxyClient::on_shutdown, shared_from_this(),
361+
std::move(completion)));
362+
// Run async_write with a single null byte:
363+
session_->stream.async_write_some(
364+
net::buffer("\0", 1),
365+
beast::bind_front_handler(&FoxyClient::on_shutdown_write,
366+
shared_from_this()));
360367
}
361368

362369
void on_shutdown(std::function<void()> completion,

0 commit comments

Comments
 (0)