Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 30 Aug 2012 12:01:17 +0400
From:      Sergey Kandaurov <pluknet@gmail.com>
To:        Vijay Singh <vijju.singh@gmail.com>
Cc:        net@freebsd.org
Subject:   Re: sorele() and ACCEPT_LOCK()
Message-ID:  <CAE-mSO%2B3r-4E034okkuNYiYtcaaQtFFgD0iAtTjLyYteaUOBjw@mail.gmail.com>
In-Reply-To: <CALCNsJTQNkPv41M0vBMoQJpFFLFHw7Q4Pf__rOmO%2BXADxAGi4g@mail.gmail.com>
References:  <CALCNsJTQNkPv41M0vBMoQJpFFLFHw7Q4Pf__rOmO%2BXADxAGi4g@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 30 August 2012 04:23, Vijay Singh <vijju.singh@gmail.com> wrote:
> Is there any reason why sorele() needs the accept lock to be held?
>
>   231 #define sorele(so) do {                                                 \
>   232         ACCEPT_LOCK_ASSERT();                                           \
>   233         SOCK_LOCK_ASSERT(so);                                           \
>   234         if ((so)->so_count <= 0)                                        \
>   235                 panic("sorele");                                        \
>   236         if (--(so)->so_count == 0)                                      \
>   237                 sofree(so);                                             \
>   238         else {                                                          \
>   239                 SOCK_UNLOCK(so);                                        \
>   240                 ACCEPT_UNLOCK();                                        \
>   241         }                                                               \
>   242 } while (0)

sofree() needs accept lock to be held to operate on a qstate field.
sofree() callers cannot be changed to push accept lock acquisition into
sofree() because that would require to reacquire sock lock around accept
lock to take locks in order; this in turn opens race.
See r136682 for details.

-- 
wbr,
pluknet



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAE-mSO%2B3r-4E034okkuNYiYtcaaQtFFgD0iAtTjLyYteaUOBjw>