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 <fengchunsong@huawei.com>
This commit is contained in:
Chunsong Feng 2021-10-13 03:55:08 +00:00
parent 86ec66a9b5
commit f696c365a2

View 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;