I'm trying to use mq_notify for a real time application to prevent the users from getting 'hung up' waiting for a response from a queue. In my code I have created mqueue_1 and send out a request to another queue, which should return a response to mqueue_1. The code then calls mq_notify before calling mq_receive for mqueue_1. I have tested killing the executable with the second queue in hopes that mq_notify will return an error since mqueue_1 should be empty. Mq_notify returns 0 and I get stuck in mq_receive. Here's my code
mqd_t md, mqueue_1;
struct mq_attr attr;
struct sigevent sigev;
attr.mq_maxmsg = 200;
attr.mq_msgsize = MSGSIZE;
attr.mq_flags = 0;
me = mq_open(qname, O_CREAT|O_RDWR, PMODE, &attr);
if (me == (mqd_t)-1)
perror("Couldn't open my message queue"
...
sprintf(message, "%s|%s|MA|WOBURN|%s||", qname, zipc, addr);
md = mq_open("/verifyaddrb", O_RDWR);
status = mq_send(md, message, strlen(message), 1);
status = mq_notify(mqueue_1, &sigev);/* status return 0 even if nothing is there */
mq_rec = mq_receive(mqueue_1, message2, MSGSIZE, 0); /* hung up here if /verifyaddrb was killed */
Also if you know of any good documentations on POSIX threads I would really appreciate it.
Thanks
mqd_t md, mqueue_1;
struct mq_attr attr;
struct sigevent sigev;
attr.mq_maxmsg = 200;
attr.mq_msgsize = MSGSIZE;
attr.mq_flags = 0;
me = mq_open(qname, O_CREAT|O_RDWR, PMODE, &attr);
if (me == (mqd_t)-1)
perror("Couldn't open my message queue"
...
sprintf(message, "%s|%s|MA|WOBURN|%s||", qname, zipc, addr);
md = mq_open("/verifyaddrb", O_RDWR);
status = mq_send(md, message, strlen(message), 1);
status = mq_notify(mqueue_1, &sigev);/* status return 0 even if nothing is there */
mq_rec = mq_receive(mqueue_1, message2, MSGSIZE, 0); /* hung up here if /verifyaddrb was killed */
Also if you know of any good documentations on POSIX threads I would really appreciate it.
Thanks