using namespace ceph::net;
+template <typename T>
+seastar::net::packet make_static_packet(const T& value) {
+ return { reinterpret_cast<const char*>(&value), sizeof(value) };
+}
+
SocketConnection::SocketConnection(Messenger *messenger,
const entity_addr_t& my_addr,
const entity_addr_t& peer_addr,
seastar::shared_future<> f = send_ready.then([this] {
k.req.stamp = ceph::coarse_real_clock::to_ceph_timespec(
ceph::coarse_real_clock::now());
- seastar::net::packet msg{reinterpret_cast<const char*>(&k.req),
- sizeof(k.req)};
- return out.write(std::move(msg));
+ return out.write(make_static_packet(k.req));
}).then([this] {
return out.flush();
});
policy.features_supported) |
policy.features_required);
h.reply.authorizer_len = authorizer_reply.length();
- return out.write(reinterpret_cast<const char*>(&h.reply), sizeof(h.reply))
+ return out.write(make_static_packet(h.reply))
.then([this, reply=std::move(authorizer_reply)]() mutable {
return out.write(std::move(reply));
}).then([this] {
h.reply.flags = h.reply.flags | CEPH_MSG_CONNECT_LOSSY;
}
h.reply.authorizer_len = authorizer_reply.length();
- return out.write(reinterpret_cast<const char*>(&h.reply), sizeof(h.reply))
+ return out.write(make_static_packet(h.reply))
.then([this, reply=std::move(authorizer_reply)]() mutable {
if (reply.length()) {
return out.write(std::move(reply));
}
}).then([this] {
if (h.reply.tag == CEPH_MSGR_TAG_SEQ) {
- return out.write(reinterpret_cast<const char*>(&in_seq),
- sizeof(in_seq)).then([this] {
- return out.flush();
+ return out.write(make_static_packet(in_seq))
+ .then([this] {
+ return out.flush();
}).then([this] {
return in.read_exactly(sizeof(seq_num_t));
}).then([this] (auto buf) {
.then([this] (auto buf) {
k.ack.stamp = *reinterpret_cast<const ceph_timespec*>(buf.get());
std::cout << "keepalive2 " << k.ack.stamp.tv_sec << std::endl;
- seastar::net::packet msg{reinterpret_cast<const char*>(&k.ack),
- sizeof(k.ack)};
- return out.write(std::move(msg));
+ return out.write(make_static_packet(k.ack));
}).then([this] {
return out.flush();
});
.then([this] (auto buf) {
auto acked_seq = reinterpret_cast<const seq_num_t*>(buf.get());
discard_up_to(&out_q, *acked_seq);
- }).then([this] {
- return out.write(reinterpret_cast<const char*>(&in_seq), sizeof(in_seq));
+ return out.write(make_static_packet(in_seq));
}).then([this] {
return out.flush();
}).then([this] {
h.connect.authorizer_len = 0;
bl.append(create_static(h.connect));
};
- return bl;
- }).then([this](bufferlist&& bl) {
return out.write(std::move(bl));
}).then([this] {
return out.flush();