Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@vyskocilm
Created March 30, 2016 14:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vyskocilm/077c89301bc360a965a06730fbf43b81 to your computer and use it in GitHub Desktop.
Save vyskocilm/077c89301bc360a965a06730fbf43b81 to your computer and use it in GitHub Desktop.
/*
* 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