}
};
-using rx_buffer_t = ceph::bufferptr;
-// FIXME: std::function in AsyncConnection requires us to be copy-
-// constructible just in the case - even if nobody actually copies
-// the std::functions there. This inhibits usage of unique_ptr of
-// ptr_node inside. Reworking the callback mechanism might help but
-// for now we can go with regular bptr.
-//
-// std::unique_ptr<buffer::ptr_node, buffer::ptr_node::disposer>;
+using rx_buffer_t =
+ std::unique_ptr<buffer::ptr_node, buffer::ptr_node::disposer>;
template <class C>
class CtRxNode : public Ct<C> {
using fn_t = Ct<C> *(C::*)(rx_buffer_t&&, int r);
fn_t _f;
+public:
mutable rx_buffer_t node;
int r;
-public:
CtRxNode(fn_t f) : _f(f) {}
void setParams(rx_buffer_t &&node, int r) {
this->node = std::move(node);
CtPtr ProtocolV2::read(CONTINUATION_RXBPTR_TYPE<ProtocolV2> &next,
rx_buffer_t &&buffer) {
- const auto len = buffer.length();
- const auto buf = buffer.c_str();
+ const auto len = buffer->length();
+ const auto buf = buffer->c_str();
+ next.node = std::move(buffer);
ssize_t r = connection->read(len, buf,
- [&next, this, bufnode = std::move(buffer)](char *buffer, int r) mutable {
- next.setParams(std::move(bufnode), r);
+ [&next, this](char *buffer, int r) {
+ next.r = r;
run_continuation(next);
});
if (r <= 0) {
// error or done synchronously
- next.setParams(rx_buffer_t(), r);
+ next.r = r;
return &next;
}
const auto& cur_rx_desc = rx_segments_desc.at(rx_segments_data.size());
rx_buffer_t rx_buffer;
try {
- rx_buffer = buffer::create_aligned(
- get_onwire_size(cur_rx_desc.length), cur_rx_desc.alignment);
+ rx_buffer = buffer::ptr_node::create(buffer::create_aligned(
+ get_onwire_size(cur_rx_desc.length), cur_rx_desc.alignment));
} catch (std::bad_alloc&) {
// Catching because of potential issues with satisfying alignment.
ldout(cct, 20) << __func__ << " can't allocate aligned rx_buffer "