Skip to content

Commit

Permalink
rsockets: Fix for cm_svc_run thread
Browse files Browse the repository at this point in the history
[ Upstream commit 24061f0 ]

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>
Signed-off-by: Nicolas Morey <nmorey@suse.com>
  • Loading branch information
linxiaochou authored and nmorey committed Aug 4, 2024
1 parent 97313bf commit 8cd6b59
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion librdmacm/rsocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -4652,8 +4652,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)
Expand Down

0 comments on commit 8cd6b59

Please sign in to comment.