From: Chunsong Feng Date: Wed, 13 Oct 2021 03:55:08 +0000 (+0000) Subject: src/msg/dpdk: reserve funcs capacity to avoid reallocation X-Git-Tag: v17.1.0~691^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F43515%2Fhead;p=ceph.git src/msg/dpdk: reserve funcs capacity to avoid reallocation 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 --- diff --git a/src/msg/async/dpdk/DPDKStack.h b/src/msg/async/dpdk/DPDKStack.h index acbac7b2011b..4eb8604c7fbe 100644 --- a/src/msg/async/dpdk/DPDKStack.h +++ b/src/msg/async/dpdk/DPDKStack.h @@ -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 &&func) override;