//my_pxmsg_mmap/mq_send.c
		/* nmsghdr     */
	if ( (freeindex = mqhdr->mqh_free) == 0)
		err_dump("mymq_send: curmsgs = %ld; free = 0", attr->mq_curmsgs);
	nmsghdr = (struct mymsg_hdr *) &mptr[freeindex];
	nmsghdr->msg_prio = prio;
	nmsghdr->msg_len = len;
	memcpy(nmsghdr + 1, ptr, len);		/*     */
	mqhdr->mqh_free = nmsghdr->msg_next;	/*      */

		/*        */
	index = mqhdr->mqh_head;
	pmsghdr = (struct mymsg_hdr *) &(mqhdr->mqh_head);
	while (index != 0) {
		msghdr = (struct mymsg_hdr *) &mptr[index];
		if (prio > msghdr->msg_prio) {
			nmsghdr->msg_next = index;
			pmsghdr->msg_next = freeindex;
			break;
		}
		index = msghdr->msg_next;
		pmsghdr = msghdr;
	}
	if (index == 0) {
			/*           */
		pmsghdr->msg_next = freeindex;
		nmsghdr->msg_next = 0;
	}
		/*    ,   mq_receive */
	if (attr->mq_curmsgs == 0)
		pthread_cond_signal(&mqhdr->mqh_wait);
	attr->mq_curmsgs++;

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

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