sorele() and ACCEPT_LOCK()
Sergey Kandaurov
pluknet at gmail.com
Thu Aug 30 08:01:19 UTC 2012
On 30 August 2012 04:23, Vijay Singh <vijju.singh at 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
More information about the freebsd-net
mailing list