0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-02 18:18:56 +02:00

ircd::client: Reference the client's request handling context via class member.

This commit is contained in:
Jason Volk 2018-04-13 17:03:17 -07:00
parent 414133ba55
commit 69aeddad61
2 changed files with 10 additions and 0 deletions

View file

@ -48,6 +48,7 @@ struct ircd::client
unique_buffer<mutable_buffer> head_buffer;
unique_buffer<mutable_buffer> content_buffer;
std::shared_ptr<socket> sock;
ctx::ctx *reqctx {nullptr};
ircd::timer timer;
size_t head_length {0};
size_t content_consumed {0};

View file

@ -328,6 +328,15 @@ void
ircd::handle_client_request(std::shared_ptr<client> client)
noexcept try
{
// The ircd::ctx now handling this request is referenced and accessible
// in client for the duration of this handling.
client->reqctx = ctx::current;
const unwind reset{[&client]
{
assert(bool(client));
client->reqctx = nullptr;
}};
if(client->main())
client->async();
else