]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
src/msg/dpdk: reserve funcs capacity to avoid reallocation 43515/head
authorChunsong Feng <fengchunsong@huawei.com>
Wed, 13 Oct 2021 03:55:08 +0000 (03:55 +0000)
committerChunsong Feng <fengchunsong@huawei.com>
Thu, 14 Oct 2021 09:55:05 +0000 (09:55 +0000)
When a new vector is added larger than then current vector capacity,
it reallocates space. lamda function accesses the previous adress will
cause a segment fault. Therefore, reserve sufficient funcs space to
avoid reallocation.

Fixes: https://tracker.ceph.com/issues/52907
Signed-off-by: Chunsong Feng <fengchunsong@huawei.com>
src/msg/async/dpdk/DPDKStack.h

index acbac7b2011babdfb863231220953cb034504c12..4eb8604c7fbed0a00671e83a8280b525445a3558 100644 (file)
@@ -254,8 +254,9 @@ class DPDKStack : public NetworkStack {
   }
 
  public:
-  explicit DPDKStack(CephContext *cct): NetworkStack(cct)
-  {}
+  explicit DPDKStack(CephContext *cct): NetworkStack(cct) {
+    funcs.reserve(cct->_conf->ms_async_op_threads);
+  }
   virtual bool support_local_listen_table() const override { return true; }
 
   virtual void spawn_worker(std::function<void ()> &&func) override;