uipc_mqueue.c (b2f92ef96bea420474618aaba46a4f17d5144d11) | uipc_mqueue.c (a6de716d7ec7b937956f665e24a30df964c0c245) |
---|---|
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 --- 1555 unchanged lines hidden (view full) --- 1564 size_t msg_len, unsigned msg_prio, int waitok, 1565 const struct timespec *abs_timeout) 1566{ 1567 struct mqueue_msg *msg; 1568 struct timespec ets, ts, ts2; 1569 struct timeval tv; 1570 int error; 1571 | 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 --- 1555 unchanged lines hidden (view full) --- 1564 size_t msg_len, unsigned msg_prio, int waitok, 1565 const struct timespec *abs_timeout) 1566{ 1567 struct mqueue_msg *msg; 1568 struct timespec ets, ts, ts2; 1569 struct timeval tv; 1570 int error; 1571 |
1572 if (msg_prio >= MQ_PRIO_MAX) 1573 return (EINVAL); |
|
1572 if (msg_len > mq->mq_msgsize) 1573 return (EMSGSIZE); 1574 msg = mqueue_loadmsg(msg_ptr, msg_len, msg_prio); 1575 if (msg == NULL) 1576 return (EFAULT); 1577 1578 /* O_NONBLOCK case */ 1579 if (!waitok) { --- 23 unchanged lines hidden (view full) --- 1603 if (error != 0) 1604 goto bad; 1605 if (ets.tv_nsec >= 1000000000 || ets.tv_nsec < 0) { 1606 error = EINVAL; 1607 goto bad; 1608 } 1609 for (;;) { 1610 ts2 = ets; | 1574 if (msg_len > mq->mq_msgsize) 1575 return (EMSGSIZE); 1576 msg = mqueue_loadmsg(msg_ptr, msg_len, msg_prio); 1577 if (msg == NULL) 1578 return (EFAULT); 1579 1580 /* O_NONBLOCK case */ 1581 if (!waitok) { --- 23 unchanged lines hidden (view full) --- 1605 if (error != 0) 1606 goto bad; 1607 if (ets.tv_nsec >= 1000000000 || ets.tv_nsec < 0) { 1608 error = EINVAL; 1609 goto bad; 1610 } 1611 for (;;) { 1612 ts2 = ets; |
1611 getnanouptime(&ts); | 1613 getnanotime(&ts); |
1612 timespecsub(&ts2, &ts); 1613 if (ts2.tv_sec < 0 || (ts2.tv_sec == 0 && ts2.tv_nsec <= 0)) { 1614 error = ETIMEDOUT; 1615 break; 1616 } 1617 TIMESPEC_TO_TIMEVAL(&tv, &ts2); 1618 error = _mqueue_send(mq, msg, tvtohz(&tv)); 1619 if (error != ETIMEDOUT) --- 14 unchanged lines hidden (view full) --- 1634{ 1635 struct mqueue_msg *msg2; 1636 int error = 0; 1637 1638 mtx_lock(&mq->mq_mutex); 1639 while (mq->mq_curmsgs >= mq->mq_maxmsg && error == 0) { 1640 if (timo < 0) { 1641 mtx_unlock(&mq->mq_mutex); | 1614 timespecsub(&ts2, &ts); 1615 if (ts2.tv_sec < 0 || (ts2.tv_sec == 0 && ts2.tv_nsec <= 0)) { 1616 error = ETIMEDOUT; 1617 break; 1618 } 1619 TIMESPEC_TO_TIMEVAL(&tv, &ts2); 1620 error = _mqueue_send(mq, msg, tvtohz(&tv)); 1621 if (error != ETIMEDOUT) --- 14 unchanged lines hidden (view full) --- 1636{ 1637 struct mqueue_msg *msg2; 1638 int error = 0; 1639 1640 mtx_lock(&mq->mq_mutex); 1641 while (mq->mq_curmsgs >= mq->mq_maxmsg && error == 0) { 1642 if (timo < 0) { 1643 mtx_unlock(&mq->mq_mutex); |
1642 mqueue_freemsg(msg); | |
1643 return (EAGAIN); 1644 } 1645 mq->mq_senders++; 1646 error = msleep(&mq->mq_senders, &mq->mq_mutex, 1647 PSOCK | PCATCH, "mqsend", timo); 1648 mq->mq_senders--; 1649 if (error == EAGAIN) 1650 error = ETIMEDOUT; --- 98 unchanged lines hidden (view full) --- 1749 return (error); 1750 if (ets.tv_nsec >= 1000000000 || ets.tv_nsec < 0) { 1751 error = EINVAL; 1752 return (error); 1753 } 1754 1755 for (;;) { 1756 ts2 = ets; | 1644 return (EAGAIN); 1645 } 1646 mq->mq_senders++; 1647 error = msleep(&mq->mq_senders, &mq->mq_mutex, 1648 PSOCK | PCATCH, "mqsend", timo); 1649 mq->mq_senders--; 1650 if (error == EAGAIN) 1651 error = ETIMEDOUT; --- 98 unchanged lines hidden (view full) --- 1750 return (error); 1751 if (ets.tv_nsec >= 1000000000 || ets.tv_nsec < 0) { 1752 error = EINVAL; 1753 return (error); 1754 } 1755 1756 for (;;) { 1757 ts2 = ets; |
1757 getnanouptime(&ts); | 1758 getnanotime(&ts); |
1758 timespecsub(&ts2, &ts); 1759 if (ts2.tv_sec < 0 || (ts2.tv_sec == 0 && ts2.tv_nsec <= 0)) { 1760 error = ETIMEDOUT; 1761 return (error); 1762 } 1763 TIMESPEC_TO_TIMEVAL(&tv, &ts2); 1764 error = _mqueue_recv(mq, &msg, tvtohz(&tv)); 1765 if (error == 0) --- 706 unchanged lines hidden --- | 1759 timespecsub(&ts2, &ts); 1760 if (ts2.tv_sec < 0 || (ts2.tv_sec == 0 && ts2.tv_nsec <= 0)) { 1761 error = ETIMEDOUT; 1762 return (error); 1763 } 1764 TIMESPEC_TO_TIMEVAL(&tv, &ts2); 1765 error = _mqueue_recv(mq, &msg, tvtohz(&tv)); 1766 if (error == 0) --- 706 unchanged lines hidden --- |