Commit 71e05dbd authored by Lucas Russo's avatar Lucas Russo

dev_io/dev_io_core.c: fix unnecessary $TERM message to actor

On DEVIO destruction, typically triggered by the
SIGINT, the main DEVIO thread receives it and
used to start sending $TERM messages to all SMIOs
(implemented as actors/threads).

However, the SMIOs also receive the signal and exited
gracefully, as usual. The problem arises by the fact
that some SMIOs exited before the DEVIO had a chance
to send the message to that specific SMIO. This would
block the zmsg_send (), as it waits forever to send
the message by default, which will never get to the
SMIO, as it does not exists anymore.

The solution would be to have a timeout for the
zmsg_send () and consider the SMIO as nonexisting
if it cannot send the message some time after.

Instead of doing this, we simply omit the message send
and call zactor_destroy () directly, as it already
implements this timeout.
parent e709c1ef
......@@ -780,28 +780,7 @@ static devio_err_e _devio_send_destruct_msg (devio_t *self, zactor_t **actor)
assert (*actor);
devio_err_e err = DEVIO_SUCCESS;
/* Send message to SMIO informing it to destroy itself */
/* This cannot fail at this point... but it can */
zmsg_t *send_msg = zmsg_new ();
ASSERT_ALLOC (send_msg, err_msg_alloc, DEVIO_ERR_ALLOC);
/* $TERM message means to selfdestruct */
zmsg_pushstr (send_msg, "$TERM");
/* Send the $TERM message to the SMIO */
int zerr = zmsg_send (&send_msg, *actor);
if (zerr != 0) {
/* Try to proceed anyway to destroy actor */
DBE_DEBUG (DBG_DEV_IO | DBG_LVL_INFO, "[dev_io_core] Could not send "
"self-destruct message to SMIO instance. \n"
"\tProceeding to destroy zactor anyway\n");
}
else {
DBE_DEBUG (DBG_DEV_IO | DBG_LVL_INFO, "[dev_io_core] Self-destruct message "
"to SMIO sent\n");
}
/* Lastly, destroy the message and actor */
zmsg_destroy (&send_msg);
DBE_DEBUG (DBG_DEV_IO | DBG_LVL_INFO, "[dev_io_core] Destroying actor %p\n", *actor);
zactor_destroy (actor);
err_msg_alloc:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment