0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-28 03:38:53 +02:00

ircd::server::tag: Use unique_buffer for cancellation mgmt.

This commit is contained in:
Jason Volk 2019-09-12 15:17:42 -07:00
parent bce4295c73
commit d6a2328fa0
2 changed files with 13 additions and 6 deletions

View file

@ -43,7 +43,7 @@ struct ircd::server::tag
state;
ctx::promise<http::code> p;
server::request *request {nullptr};
std::unique_ptr<char[]> cancellation;
unique_buffer<mutable_buffer> cancellation;
void set_exception(std::exception_ptr);
template<class T, class... args> void set_exception(args&&...);

View file

@ -2575,8 +2575,15 @@ noexcept
// user's buffers.
assert(!tag.cancellation);
tag.cancellation = std::make_unique<char[]>(cancellation_size);
char *ptr{tag.cancellation.get()};
tag.cancellation = unique_buffer<mutable_buffer>
{
cancellation_size
};
char *ptr
{
data(tag.cancellation)
};
const mutable_buffer out_head{ptr, size(request.out.head)};
tag.request->out.head = out_head;
@ -2601,7 +2608,7 @@ noexcept
}
else tag.request->in.content = request.in.content;
assert(size_t(std::distance(tag.cancellation.get(), ptr)) == cancellation_size);
assert(size_t(std::distance(data(tag.cancellation), ptr)) == cancellation_size);
// If the head is not completely written we have to copy the remainder from where
// the socket left off.
@ -2756,7 +2763,7 @@ noexcept
// place in addition to an cancellation buffer. The existence of this
// cancellation buffer indicates that we must delete the request here.
// This is a little hacky but it gets the job done.
if(bool(tag.cancellation))
if(!!tag.cancellation)
delete &request;
}
@ -4021,7 +4028,7 @@ bool
ircd::server::tag::canceled()
const
{
return bool(cancellation);
return !!cancellation;
}
bool