Skip to content

Instantly share code, notes, and snippets.

@vyskocilm
Created Mar 30, 2016
Embed
What would you like to do?
/*
* Test the fact it's not a good idea to call mlm_client API when zsys_interrupted == 1;
*/
#define MLM_BUILD_DRAFT_API
#include <malamute.h>
int main ()
{
static const char *endpoint = "ipc://@/malamute-zsys-interrupted";
zactor_t *server = zactor_new (mlm_server, "Malamute-test");
zstr_sendx (server, "BIND", endpoint, NULL);
mlm_client_t *client = mlm_client_new ();
mlm_client_connect (client, endpoint, 5000, "cl");
zsys_debug ("CLIENT CONNECTED to endpoint");
zmsg_t *msg = zmsg_new ();
zmsg_addstr (msg, "Hello, world");
zsys_interrupted = 1;
zsys_debug ("CLIENT before sleep");
zclock_sleep (5000);
zsys_debug ("CLIENT before sendto");
int r = mlm_client_sendto (client, "some-mailbox", "SUBJECT", NULL, 1000, &msg);
zsys_debug ("CLIENT sent msg");
assert (r != -1);
zsys_debug ("r=%d", r);
zclock_sleep (250);
zsys_debug ("DESTROY");
mlm_client_destroy (&client);
zactor_destroy (&server);
zsys_debug ("End;");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment