]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
msg/async: move v1 member init to header
authorPatrick Donnelly <pdonnell@redhat.com>
Fri, 29 Aug 2025 13:35:15 +0000 (09:35 -0400)
committerPatrick Donnelly <pdonnell@ibm.com>
Mon, 5 Jan 2026 21:23:39 +0000 (16:23 -0500)
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
src/msg/async/ProtocolV1.cc
src/msg/async/ProtocolV1.h

index fc4f2b483d76f3f2df7e0874a4facda0bc7278bf..9e0e740ec80f7c00a38815e0a65a2200a69d235a 100644 (file)
@@ -62,28 +62,16 @@ static void alloc_aligned_buffer(ceph::buffer::list &data, unsigned len, unsigne
  **/
 
 ProtocolV1::ProtocolV1(AsyncConnection *connection)
-    : Protocol(1, connection),
-      temp_buffer(nullptr),
-      can_write(WriteStatus::NOWRITE),
-      keepalive(false),
-      connect_seq(0),
-      peer_global_seq(0),
-      msg_left(0),
-      cur_msg_size(0),
-      replacing(false),
-      is_reset_from_peer(false),
-      once_ready(false),
-      state(NONE),
-      global_seq(0),
-      wait_for_seq(false) {
-  temp_buffer = new char[4096];
-}
-
-ProtocolV1::~ProtocolV1() {
+    : Protocol(1, connection)
+{
+  ldout(cct, 5) << "con" << dendl;
+}
+
+ProtocolV1::~ProtocolV1()
+{
+  ldout(cct, 5) << "des" << dendl;
   ceph_assert(out_q.empty());
   ceph_assert(sent.empty());
-
-  delete[] temp_buffer;
 }
 
 void ProtocolV1::connect() {
@@ -439,7 +427,8 @@ void ProtocolV1::run_continuation(CtPtr pcontinuation) {
 CtPtr ProtocolV1::read(CONTINUATION_RX_TYPE<ProtocolV1> &next,
                        int len, char *buffer) {
   if (!buffer) {
-    buffer = temp_buffer;
+    /* FIXME: why not len = sizeof temp_buffer??? */
+    buffer = temp_buffer.data();
   }
   ssize_t r = connection->read(len, buffer,
                                [&next, this](char *buffer, int r) {
index 200d01ad35c66df8669cdc0360a70c58d2a58b50..01a3c66b903d8600c45fffe65fb179241a65a530 100644 (file)
@@ -104,10 +104,10 @@ protected:
     return statenames[state];
   }
 
-  char *temp_buffer;
+  std::array<char, 4096> temp_buffer;
 
   enum class WriteStatus { NOWRITE, REPLACING, CANWRITE, CLOSED };
-  std::atomic<WriteStatus> can_write;
+  std::atomic<WriteStatus> can_write = WriteStatus::NOWRITE;
   std::deque<MessageRef> sent;  // the first ceph::buffer::list need to inject seq
   //struct for outbound msgs
   struct out_q_entry_t {
@@ -122,10 +122,11 @@ protected:
    */
   std::map<int, std::deque<out_q_entry_t>, std::greater<int>> out_q;
 
-  bool keepalive;
+  bool keepalive = false;
   bool write_in_progress = false;
 
-  __u32 connect_seq, peer_global_seq;
+  __u32 connect_seq = 0;
+  __u32 peer_global_seq = 0;
   std::atomic<uint64_t> in_seq{0};
   std::atomic<uint64_t> out_seq{0};
   std::atomic<uint64_t> ack_left{0};
@@ -141,23 +142,23 @@ protected:
   utime_t backoff;  // backoff time
   utime_t recv_stamp;
   utime_t throttle_stamp;
-  unsigned msg_left;
-  uint64_t cur_msg_size;
+  unsigned msg_left = 0;
+  uint64_t cur_msg_size = 0;
   ceph_msg_header current_header;
   ceph::buffer::list data_buf;
   ceph::buffer::list::iterator data_blp;
   ceph::buffer::list front, middle, data;
 
-  bool replacing;  // when replacing process happened, we will reply connect
+  bool replacing = false;  // when replacing process happened, we will reply connect
                    // side with RETRY tag and accept side will clear replaced
                    // connection. So when connect side reissue connect_msg,
                    // there won't exists conflicting connection so we use
                    // "replacing" to skip RESETSESSION to avoid detect wrong
                    // presentation
-  bool is_reset_from_peer;
-  bool once_ready;
+  bool is_reset_from_peer = false;
+  bool once_ready = false;
 
-  State state;
+  State state = NONE;
 
   void run_continuation(CtPtr pcontinuation);
   CtPtr read(CONTINUATION_RX_TYPE<ProtocolV1> &next, int len,
@@ -243,7 +244,7 @@ public:
 
   // Client Protocol
 private:
-  int global_seq;
+  int global_seq = 0;
 
   CONTINUATION_DECL(ProtocolV1, send_client_banner);
   WRITE_HANDLER_CONTINUATION_DECL(ProtocolV1, handle_client_banner_write);
@@ -275,7 +276,7 @@ private:
 
   // Server Protocol
 protected:
-  bool wait_for_seq;
+  bool wait_for_seq = false;
 
   CONTINUATION_DECL(ProtocolV1, send_server_banner);
   WRITE_HANDLER_CONTINUATION_DECL(ProtocolV1, handle_server_banner_write);