From owner-freebsd-net@FreeBSD.ORG Thu Aug 30 08:01:18 2012 Return-Path: Delivered-To: net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id EB5E9106566C for ; Thu, 30 Aug 2012 08:01:18 +0000 (UTC) (envelope-from pluknet@gmail.com) Received: from mail-iy0-f182.google.com (mail-iy0-f182.google.com [209.85.210.182]) by mx1.freebsd.org (Postfix) with ESMTP id AF5B18FC0C for ; Thu, 30 Aug 2012 08:01:18 +0000 (UTC) Received: by ialo14 with SMTP id o14so3550176ial.13 for ; Thu, 30 Aug 2012 01:01:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=YBZRkFol7dDBVf1NUQ/dnhOM8d73QLztN/7VpAzA6UY=; b=hD+lgwVKE+TY/O69vOhCMb8ejB1WCw3AZVPewchXL2HqMPlufxmwjwmeKBB3IOXHfy TH27dCBGYTfPrChLvLrFhXJsBrFmUlr0z6PA3R0kj8z2P7QY/nrpM8iLzzBfIrF3h6H2 xk230viaoamnq0dBRls2m6fRDftoYEcyzp770o4ewoDL/Inm5qAnZXReZkoseW1sWQQX Egljt+iaRMX4rsAxKNtnvFr8QJE/XgBl+/AwxYyFu7F6QDiWqilGsRR/Cb0lgwc03Yxj J8qZ0RkZCZ6HCiVsNzlP1cfWdDOo38S0kLWXnDSjYdUJek6dhwC/AOUjijgbe+q4F2q3 Lq1A== MIME-Version: 1.0 Received: by 10.50.40.225 with SMTP id a1mr4574375igl.51.1346313677641; Thu, 30 Aug 2012 01:01:17 -0700 (PDT) Received: by 10.64.165.34 with HTTP; Thu, 30 Aug 2012 01:01:17 -0700 (PDT) In-Reply-To: References: Date: Thu, 30 Aug 2012 12:01:17 +0400 Message-ID: From: Sergey Kandaurov To: Vijay Singh Content-Type: text/plain; charset=ISO-8859-1 Cc: net@freebsd.org Subject: Re: sorele() and ACCEPT_LOCK() X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Aug 2012 08:01:19 -0000 On 30 August 2012 04:23, Vijay Singh 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