malamute
malamute copied to clipboard
Client not disconnecting from server when the program is interrupted
Hi, In mlm_client_destroy
function, mlm_client_destructor
will not be called when zsys_interrupted
occurs. Is it by design, not to disconnect from the server when an interrupt occurs? could you explain the reason behind it? Thank you.
void
mlm_client_destroy (mlm_client_t **self_p)
{
assert (self_p);
if (*self_p) {
mlm_client_t *self = *self_p;
if (self->actor && !zsys_interrupted) {
// Before destroying the actor we have to flush any pending
// traffic on the msgpipe, otherwise it gets lost in a fire and
// forget scenario. We do this by sending $FLUSH to the msgpipe
// and waiting for a signal back on the cmdpipe.
if (zstr_send (self->msgpipe, "$FLUSH") == 0)
zsock_wait (self->actor);
mlm_client_destructor (self);
}
zactor_destroy (&self->actor);
zsock_destroy (&self->msgpipe);
zstr_free (&self->command);
zstr_free (&self->reason);
free (self);
*self_p = NULL;
}
}
Hi, dharanikumarsrvnrntbci, short answer yes!
mlm_client_destructor
calls s_accept_reply
as do any reply accepting messages. s_accept_reply
itself will immediately return with -1 if zsys_interrupted is set because s_accept_reply
may take an infinite amount of time to complete. We use zsys_interrupted to terminate gracefully and waiting an unknown amount of time for an answer isn't graceful at least from the client's perspective.
Hi sappo, I can understand s_accept_reply is used for many function, and it should be terminated when interrupted in those scenarios. But leaving s_accept_reply usage aside, when client being destructed, it needs to inform the server about disconnecting. isn't it? Just curious to know.