Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client not disconnecting from server when the program is interrupted #183

Open
dharanikumar-s opened this issue May 12, 2016 · 2 comments
Open

Comments

@dharanikumar-s
Copy link

Hi, In mlm_client_destroyfunction, mlm_client_destructorwill not be called when zsys_interruptedoccurs. 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;
    }
}
@sappo
Copy link
Member

sappo commented May 12, 2016

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.

@dharanikumar-s
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants