mirror of
https://github.com/matrix-construct/construct
synced 2024-11-16 06:51:08 +01:00
ircd::server::tag: Use unique_buffer for cancellation mgmt.
This commit is contained in:
parent
bce4295c73
commit
d6a2328fa0
2 changed files with 13 additions and 6 deletions
|
@ -43,7 +43,7 @@ struct ircd::server::tag
|
||||||
state;
|
state;
|
||||||
ctx::promise<http::code> p;
|
ctx::promise<http::code> p;
|
||||||
server::request *request {nullptr};
|
server::request *request {nullptr};
|
||||||
std::unique_ptr<char[]> cancellation;
|
unique_buffer<mutable_buffer> cancellation;
|
||||||
|
|
||||||
void set_exception(std::exception_ptr);
|
void set_exception(std::exception_ptr);
|
||||||
template<class T, class... args> void set_exception(args&&...);
|
template<class T, class... args> void set_exception(args&&...);
|
||||||
|
|
|
@ -2575,8 +2575,15 @@ noexcept
|
||||||
// user's buffers.
|
// user's buffers.
|
||||||
|
|
||||||
assert(!tag.cancellation);
|
assert(!tag.cancellation);
|
||||||
tag.cancellation = std::make_unique<char[]>(cancellation_size);
|
tag.cancellation = unique_buffer<mutable_buffer>
|
||||||
char *ptr{tag.cancellation.get()};
|
{
|
||||||
|
cancellation_size
|
||||||
|
};
|
||||||
|
|
||||||
|
char *ptr
|
||||||
|
{
|
||||||
|
data(tag.cancellation)
|
||||||
|
};
|
||||||
|
|
||||||
const mutable_buffer out_head{ptr, size(request.out.head)};
|
const mutable_buffer out_head{ptr, size(request.out.head)};
|
||||||
tag.request->out.head = out_head;
|
tag.request->out.head = out_head;
|
||||||
|
@ -2601,7 +2608,7 @@ noexcept
|
||||||
}
|
}
|
||||||
else tag.request->in.content = request.in.content;
|
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
|
// If the head is not completely written we have to copy the remainder from where
|
||||||
// the socket left off.
|
// the socket left off.
|
||||||
|
@ -2756,7 +2763,7 @@ noexcept
|
||||||
// place in addition to an cancellation buffer. The existence of this
|
// place in addition to an cancellation buffer. The existence of this
|
||||||
// cancellation buffer indicates that we must delete the request here.
|
// cancellation buffer indicates that we must delete the request here.
|
||||||
// This is a little hacky but it gets the job done.
|
// This is a little hacky but it gets the job done.
|
||||||
if(bool(tag.cancellation))
|
if(!!tag.cancellation)
|
||||||
delete &request;
|
delete &request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4021,7 +4028,7 @@ bool
|
||||||
ircd::server::tag::canceled()
|
ircd::server::tag::canceled()
|
||||||
const
|
const
|
||||||
{
|
{
|
||||||
return bool(cancellation);
|
return !!cancellation;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
Loading…
Reference in a new issue