uipc_mqueue.c (61d3a4efc24f240ff5625b9220aa441ed82c2fae) uipc_mqueue.c (0f180a7cce5bed801060557dd5bdbad64318d3c6)
1/*-
2 * Copyright (c) 2005 David Xu <davidxu@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 1643 unchanged lines hidden (view full) ---

1652 mtx_lock(&mq->mq_mutex);
1653 while (mq->mq_curmsgs >= mq->mq_maxmsg && error == 0) {
1654 if (timo < 0) {
1655 mtx_unlock(&mq->mq_mutex);
1656 return (EAGAIN);
1657 }
1658 mq->mq_senders++;
1659 error = msleep(&mq->mq_senders, &mq->mq_mutex,
1/*-
2 * Copyright (c) 2005 David Xu <davidxu@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 1643 unchanged lines hidden (view full) ---

1652 mtx_lock(&mq->mq_mutex);
1653 while (mq->mq_curmsgs >= mq->mq_maxmsg && error == 0) {
1654 if (timo < 0) {
1655 mtx_unlock(&mq->mq_mutex);
1656 return (EAGAIN);
1657 }
1658 mq->mq_senders++;
1659 error = msleep(&mq->mq_senders, &mq->mq_mutex,
1660 curthread->td_priority | PCATCH, "mqsend", timo);
1660 PCATCH, "mqsend", timo);
1661 mq->mq_senders--;
1662 if (error == EAGAIN)
1663 error = ETIMEDOUT;
1664 }
1665 if (mq->mq_curmsgs >= mq->mq_maxmsg) {
1666 mtx_unlock(&mq->mq_mutex);
1667 return (error);
1668 }

--- 135 unchanged lines hidden (view full) ---

1804 mtx_lock(&mq->mq_mutex);
1805 while ((*msg = TAILQ_FIRST(&mq->mq_msgq)) == NULL && error == 0) {
1806 if (timo < 0) {
1807 mtx_unlock(&mq->mq_mutex);
1808 return (EAGAIN);
1809 }
1810 mq->mq_receivers++;
1811 error = msleep(&mq->mq_receivers, &mq->mq_mutex,
1661 mq->mq_senders--;
1662 if (error == EAGAIN)
1663 error = ETIMEDOUT;
1664 }
1665 if (mq->mq_curmsgs >= mq->mq_maxmsg) {
1666 mtx_unlock(&mq->mq_mutex);
1667 return (error);
1668 }

--- 135 unchanged lines hidden (view full) ---

1804 mtx_lock(&mq->mq_mutex);
1805 while ((*msg = TAILQ_FIRST(&mq->mq_msgq)) == NULL && error == 0) {
1806 if (timo < 0) {
1807 mtx_unlock(&mq->mq_mutex);
1808 return (EAGAIN);
1809 }
1810 mq->mq_receivers++;
1811 error = msleep(&mq->mq_receivers, &mq->mq_mutex,
1812 curthread->td_priority | PCATCH, "mqrecv", timo);
1812 PCATCH, "mqrecv", timo);
1813 mq->mq_receivers--;
1814 if (error == EAGAIN)
1815 error = ETIMEDOUT;
1816 }
1817 if (*msg != NULL) {
1818 error = 0;
1819 TAILQ_REMOVE(&mq->mq_msgq, *msg, msg_link);
1820 mq->mq_curmsgs--;

--- 662 unchanged lines hidden ---
1813 mq->mq_receivers--;
1814 if (error == EAGAIN)
1815 error = ETIMEDOUT;
1816 }
1817 if (*msg != NULL) {
1818 error = 0;
1819 TAILQ_REMOVE(&mq->mq_msgq, *msg, msg_link);
1820 mq->mq_curmsgs--;

--- 662 unchanged lines hidden ---