Commit 8f7a4a82 authored by Lucas Russo's avatar Lucas Russo

src/{dev_io,sm_io}/*: update zthread to zactor API (CZMQ 3.0.0)

parent 6b83d03c
......@@ -306,11 +306,21 @@ devio_err_e devio_register_sm (devio_t *self, uint32_t smio_id, uint64_t base,
th_config_args->log_file = self->log_file;
th_config_args->inst_id = inst_id;
/* Create detached thread just for configuring the new recently created SMIO */
zerr = zthread_new (smio_config_defaults, th_config_args);
ASSERT_TEST (zerr == 0, "Could not spawn config thread",
/* Create actor just for configuring the new recently created SMIO */
zactor_t *config_actor = zactor_new (smio_config_defaults, th_config_args);
ASSERT_TEST (config_actor != NULL, "Could not spawn config thread",
err_spawn_config_thread);
/* Ok, we've created our actor. Now, we wait for it to signal its end */
zsock_wait (config_actor);
/* Now, we send a TERM message to the actor, indicating we want it to
* end */
zerr = zstr_sendx (config_actor, "$TERM", NULL);
/* ASSERT_TEST (zerr != -1, "Could send $TERM message to actor",
err_end_config_thread); */
/* Lastly, destroy the actor */
zactor_destroy (&config_actor);
/* stop on first match */
break;
}
......
......@@ -130,9 +130,11 @@ err_inst_id_str_alloc:
/************************************************************/
/*************** SMIO Config Thread entry-point ************/
/************************************************************/
void *smio_config_defaults (void *args)
void smio_config_defaults (zsock_t *pipe, void *args)
{
th_config_args_t *th_args = (th_config_args_t *) args;
/* Signal parent we are initializing */
zsock_signal (pipe, 0);
/* We must export our service as the combination of the
* devio name (coming from devio parent) and our own name ID
......@@ -151,14 +153,34 @@ void *smio_config_defaults (void *args)
SMIO_DISPATCH_FUNC_WRAPPER_GEN(config_defaults, th_args->broker,
smio_service, th_args->log_file);
/* We've finished configuring the SMIO. Tell DEVIO we are done */
zsock_signal (pipe, 0);
/* Wait for $TERM message from DEVIO to end */
bool terminated = false;
while (!terminated) {
zmsg_t *msg = zmsg_recv (pipe);
if (msg == NULL) {
break; /* Interrupted */
}
char *command = zmsg_popstr (msg);
if (streq (command, "$TERM")) {
terminated = true;
}
free (command);
zmsg_destroy (&msg);
}
DBE_DEBUG (DBG_SM_IO | DBG_LVL_INFO, "[sm_io_bootstrap] Config Thread %s "
"exiting\n", smio_service);
"terminating with %s\n", smio_service, (terminated)? "success" : "error");
free (smio_service);
err_smio_service_alloc:
free (inst_id_str);
err_inst_id_str_alloc:
free (th_args);
return NULL;
}
/************************************************************/
......
......@@ -87,7 +87,7 @@ typedef struct _th_config_args_t th_config_args_t;
/************************ Our methods ***********************/
/************************************************************/
void smio_startup (zsock_t *pipe, void *args);
void *smio_config_defaults (void *args);
void smio_config_defaults (zsock_t *pipe, void *args);
struct _smio_t *smio_new (th_boot_args_t *args, zsock_t *pipe, char *service);
smio_err_e smio_destroy (struct _smio_t **self_p);
smio_err_e smio_loop (struct _smio_t *self);
......
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