From: Kefu Chai Date: Tue, 2 Jan 2018 08:03:30 +0000 (+0800) Subject: msg: SocketConnection use consumption_result_type X-Git-Tag: v14.0.1~1115^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b3e0558f424f2571bd25909fb930dc0d987a7e37;p=ceph.git msg: SocketConnection use consumption_result_type Signed-off-by: Kefu Chai --- diff --git a/src/crimson/net/SocketConnection.cc b/src/crimson/net/SocketConnection.cc index 3fc03cb0e1b9..87905114b3fa 100644 --- a/src/crimson/net/SocketConnection.cc +++ b/src/crimson/net/SocketConnection.cc @@ -56,20 +56,23 @@ struct bufferlist_consumer { : bl(bl), remaining(remaining) {} using tmp_buf = seastar::temporary_buffer; - using unconsumed_remainder = std::experimental::optional; + using consumption_result_type = typename seastar::input_stream::consumption_result_type; // consume some or all of a buffer segment - seastar::future operator()(tmp_buf&& data) { + seastar::future operator()(tmp_buf&& data) { if (remaining >= data.size()) { // consume the whole buffer remaining -= data.size(); bl.append(buffer::create_foreign(std::move(data))); if (remaining > 0) { // return none to request more segments - return seastar::make_ready_future(); + return seastar::make_ready_future( + seastar::continue_consuming{}); + } else { + // return an empty buffer to singal that we're done + return seastar::make_ready_future( + consumption_result_type::stop_consuming_type({})); } - // return an empty buffer to singal that we're done - return seastar::make_ready_future(tmp_buf{}); } if (remaining > 0) { // consume the front @@ -78,7 +81,8 @@ struct bufferlist_consumer { remaining = 0; } // give the rest back to signal that we're done - return seastar::make_ready_future(std::move(data)); + return seastar::make_ready_future( + consumption_result_type::stop_consuming_type{std::move(data)}); }; };