When short of mbufs or mbuf clusters, we sleep on appropriate "counters."
The counters are incremented when a thread goes to sleep and decremented either when a thread is woken up by another thread or when the sleep times out. There existed a race where the sleep count could be decremented twice resulting in an eventual underflow. Move the decrementing of the "counters" to the thread initiating the sleep and thus remedy the problem.
This commit is contained in:
parent
08b2398e6d
commit
56acb799b2
@ -353,9 +353,9 @@ m_mballoc_wait(void)
|
||||
|
||||
if (p == NULL) {
|
||||
m_mballoc_wid++;
|
||||
if (msleep(&m_mballoc_wid, &mmbfree.m_mtx, PVM, "mballc",
|
||||
mbuf_wait) == EWOULDBLOCK)
|
||||
m_mballoc_wid--;
|
||||
msleep(&m_mballoc_wid, &mmbfree.m_mtx, PVM, "mballc",
|
||||
mbuf_wait);
|
||||
m_mballoc_wid--;
|
||||
|
||||
/*
|
||||
* Try again (one last time).
|
||||
@ -463,9 +463,8 @@ m_clalloc_wait(void)
|
||||
caddr_t p = NULL;
|
||||
|
||||
m_clalloc_wid++;
|
||||
if (msleep(&m_clalloc_wid, &mclfree.m_mtx, PVM, "mclalc", mbuf_wait)
|
||||
== EWOULDBLOCK)
|
||||
m_clalloc_wid--;
|
||||
msleep(&m_clalloc_wid, &mclfree.m_mtx, PVM, "mclalc", mbuf_wait);
|
||||
m_clalloc_wid--;
|
||||
|
||||
/*
|
||||
* Now that we (think) that we've got something, try again.
|
||||
|
@ -273,10 +273,8 @@ struct mcntfree_lst {
|
||||
* Must be called with the appropriate mutex held.
|
||||
*/
|
||||
#define MBWAKEUP(m_wid) do { \
|
||||
if ((m_wid)) { \
|
||||
m_wid--; \
|
||||
if ((m_wid)) \
|
||||
wakeup_one(&(m_wid)); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user