//my_pxmsg_mmap/mq_receive.c
	if ( (index = mqhdr->mqh_head) == 0)
		err_dump("mymq_receive: curmsgs = %ld; head = 0", attr->mq_curmsgs);

	msghdr = (struct mymsg_hdr *) &mptr[index];
	mqhdr->mqh_head = msghdr->msg_next;	/*    */
	len = msghdr->msg_len;
	memcpy(ptr, msghdr + 1, len);		/*    */
	if (priop != NULL)
		*priop = msghdr->msg_prio;

		/*          */
	msghdr->msg_next = mqhdr->mqh_free;
	mqhdr->mqh_free = index;

		/*   ,    mq_send */
	if (attr->mq_curmsgs == attr->mq_maxmsg)
		pthread_cond_signal(&mqhdr->mqh_wait);
	attr->mq_curmsgs--;

	pthread_mutex_unlock(&mqhdr->mqh_lock);
	return(len);

err:
	pthread_mutex_unlock(&mqhdr->mqh_lock);
	return(-1);
}
