From d6a2328fa04dcf367c305cc2a63578686f940cbe Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Thu, 12 Sep 2019 15:17:42 -0700 Subject: [PATCH] ircd::server::tag: Use unique_buffer for cancellation mgmt. --- include/ircd/server/tag.h | 2 +- ircd/server.cc | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/include/ircd/server/tag.h b/include/ircd/server/tag.h index 50690df02..61431359d 100644 --- a/include/ircd/server/tag.h +++ b/include/ircd/server/tag.h @@ -43,7 +43,7 @@ struct ircd::server::tag state; ctx::promise p; server::request *request {nullptr}; - std::unique_ptr cancellation; + unique_buffer cancellation; void set_exception(std::exception_ptr); template void set_exception(args&&...); diff --git a/ircd/server.cc b/ircd/server.cc index cc6a84f44..b9146f318 100644 --- a/ircd/server.cc +++ b/ircd/server.cc @@ -2575,8 +2575,15 @@ noexcept // user's buffers. assert(!tag.cancellation); - tag.cancellation = std::make_unique(cancellation_size); - char *ptr{tag.cancellation.get()}; + tag.cancellation = unique_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