Fix a logic error introduced with mandatory mbuf cluster refcounting and

freeing of mbufs+clusters back to the packet zone.
This commit is contained in:
Andre Oppermann 2005-11-04 17:20:53 +00:00
parent 393109a1a2
commit a5f7708723
2 changed files with 7 additions and 6 deletions

View File

@ -395,11 +395,10 @@ mb_ctor_clust(void *mem, int size, void *arg, int how)
static void
mb_dtor_clust(void *mem, int size, void *arg)
{
u_int *refcnt;
refcnt = uma_find_refcnt(zone_clust, mem);
KASSERT(*refcnt == 1, ("%s: refcnt incorrect %u", __func__, *refcnt));
*refcnt = 0;
KASSERT(*(uma_find_refcnt(zone_clust, mem)) <= 1,
("%s: refcnt incorrect %u", __func__,
*(uma_find_refcnt(zone_clust, mem))) );
#ifdef INVARIANTS
trash_dtor(mem, size, arg);
#endif

View File

@ -215,9 +215,11 @@ mb_free_ext(struct mbuf *m)
/* Free attached storage if this mbuf is the only reference to it. */
if (*(m->m_ext.ref_cnt) == 1 ||
atomic_fetchadd_int(m->m_ext.ref_cnt, -1) == 1) {
atomic_fetchadd_int(m->m_ext.ref_cnt, -1) == 0) {
switch (m->m_ext.ext_type) {
case EXT_CLUSTER:
case EXT_CLUSTER: /* The packet zone is special. */
if (*(m->m_ext.ref_cnt) == 0)
*(m->m_ext.ref_cnt) = 1;
uma_zfree(zone_pack, m);
return; /* Job done. */
break;