Skip to content

Commit

Permalink
rsockets: Fix for cm_svc_run thread
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
linxiaochou committed Jul 25, 2024
1 parent f6ff7a3 commit 24061f0
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 @@ -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)
Expand Down

0 comments on commit 24061f0

Please sign in to comment.