* Alfred Perlstein <[EMAIL PROTECTED]> [001212 01:44] wrote:
> grr...
>
> considering this:
>
> #define MEXT_IS_REF(m) ((m)->m_ext.ref_cnt->refcnt > 1)
>
> #define MEXT_REM_REF(m) do { \
> KASSERT((m)->m_ext.ref_cnt->refcnt > 0, ("m_ext refcnt < 0")); \
> atomic_subtract_long(&((m)->m_ext.ref_cnt->refcnt), 1); \
> } while(0)
>
> this:
>
> #define MEXTFREE(m) do { \
> struct mbuf *_mmm = (m); \
> \
> if (MEXT_IS_REF(_mmm)) \
> MEXT_REM_REF(_mmm); \
>
>
> is not mpsafe. we _NEED_ some type that allows atomic dec and test
> for 0.
Sorry, I didn't explain why this is broken, it looks safe because
if it's 1 then only "we" reference it. This is incorrect:
(m)->m_ext.ref_cnt->refcnt == 2
thread a thread b
if (MEXT_IS_REF(m))
if (MEXT_IS_REF(m))
MEXT_REM_REF(m);
MEXT_REM_REF(m);
now... (m)->m_ext.ref_cnt->refcnt == 0.
oops, now the destructor never gets called and we just leaked a
mbuf cluster.
--
-Alfred Perlstein - [[EMAIL PROTECTED]|[EMAIL PROTECTED]]
"I have the heart of a child; I keep it in a jar on my desk."
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-net" in the body of the message