From 24061f015bd948ff26ad1fb0dd4a69f9503ae7da Mon Sep 17 00:00:00 2001 From: linxiaochou <929331108@qq.com> Date: Wed, 24 Jul 2024 16:23:51 +0800 Subject: [PATCH] rsockets: Fix for cm_svc_run thread When the cm_svc_run thread starts, svc->contexts will be initialized with four elements. When reallocating memory due to an increased element count, svc->contexts will point to new addresses, whereas the fds variable in the cm_svc_run thread is free of the address, which will result in subsequent cm_svc_run threads running incorrectly. So we need to update the fds variable every time the cm_svc_process_sock function is processed. Fixes: b60c79d ("rsockets: Use service thread to accept connections") Signed-off-by: linxiaochou <929331108@qq.com> --- librdmacm/rsocket.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/librdmacm/rsocket.c b/librdmacm/rsocket.c index 604b8b4fe..003dabfde 100644 --- a/librdmacm/rsocket.c +++ b/librdmacm/rsocket.c @@ -4678,8 +4678,11 @@ static void *cm_svc_run(void *arg) fds[i].revents = 0; poll(fds, svc->cnt + 1, -1); - if (fds[0].revents) + if (fds[0].revents) { cm_svc_process_sock(svc); + /* svc->contexts may have been reallocated, so need to assign again */ + fds = svc->contexts; + } for (i = 1; i <= svc->cnt; i++) { if (!fds[i].revents)