Skip to content

Commit

Permalink
ipc: end multiprocess thread during cleanup
Browse files Browse the repository at this point in the history
[ upstream commit 6e858b4 ]

When rte_eal_cleanup is called, all control threads should exit.
For the mp thread, this best handled by closing the mp_socket
and letting the thread see that.

This also fixes potential problems where the mp_socket gets
another hard error, and the thread runs away repeating itself
by reading the same error.

Fixes: 85d6815 ("eal: close multi-process socket during cleanup")

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
  • Loading branch information
shemminger authored and bluca committed Feb 17, 2022
1 parent b8e818d commit 184d1f7
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions lib/librte_eal/common/eal_common_proc.c
Expand Up @@ -282,8 +282,17 @@ read_msg(struct mp_msg_internal *m, struct sockaddr_un *s)
msgh.msg_control = control;
msgh.msg_controllen = sizeof(control);

retry:
msglen = recvmsg(mp_fd, &msgh, 0);

/* zero length message means socket was closed */
if (msglen == 0)
return 0;

if (msglen < 0) {
if (errno == EINTR)
goto retry;

RTE_LOG(ERR, EAL, "recvmsg failed, %s\n", strerror(errno));
return -1;
}
Expand Down Expand Up @@ -311,7 +320,7 @@ read_msg(struct mp_msg_internal *m, struct sockaddr_un *s)
RTE_LOG(ERR, EAL, "invalid received data length\n");
return -1;
}
return 0;
return msglen;
}

static void
Expand Down Expand Up @@ -385,8 +394,13 @@ mp_handle(void *arg __rte_unused)
struct sockaddr_un sa;

while (mp_fd >= 0) {
if (read_msg(&msg, &sa) == 0)
process_msg(&msg, &sa);
int ret;

ret = read_msg(&msg, &sa);
if (ret <= 0)
break;

process_msg(&msg, &sa);
}

return NULL;
Expand Down

0 comments on commit 184d1f7

Please sign in to comment.