From owner-p4-projects@FreeBSD.ORG Thu Dec 11 15:21:59 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 4084016A4D0; Thu, 11 Dec 2003 15:21:59 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1AC9716A4CE for ; Thu, 11 Dec 2003 15:21:59 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 58E3443D2D for ; Thu, 11 Dec 2003 15:21:58 -0800 (PST) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.9/8.12.9) with ESMTP id hBBNLwXJ054530 for ; Thu, 11 Dec 2003 15:21:58 -0800 (PST) (envelope-from sam@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.9/8.12.9/Submit) id hBBNLveu054527 for perforce@freebsd.org; Thu, 11 Dec 2003 15:21:57 -0800 (PST) (envelope-from sam@freebsd.org) Date: Thu, 11 Dec 2003 15:21:57 -0800 (PST) Message-Id: <200312112321.hBBNLveu054527@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to sam@freebsd.org using -f From: Sam Leffler To: Perforce Change Reviews Subject: PERFORCE change 43832 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Dec 2003 23:21:59 -0000 http://perforce.freebsd.org/chv.cgi?CH=43832 Change 43832 by sam@sam_ebb on 2003/12/11 15:21:22 drop locks before calling sonewconn to avoid recursion on the unpcb head lock and to avoid holding locks over malloc Affected files ... .. //depot/projects/netperf+sockets/sys/kern/uipc_usrreq.c#5 edit Differences ... ==== //depot/projects/netperf+sockets/sys/kern/uipc_usrreq.c#5 (text+ko) ==== @@ -839,8 +839,19 @@ goto bad; } if (so->so_proto->pr_flags & PR_CONNREQUIRED) { - if ((so2->so_options & SO_ACCEPTCONN) == 0 || - (so3 = sonewconn(so2, 0)) == 0) { + if (so2->so_options & SO_ACCEPTCONN) { + /* + * NB: drop locks here so unp_attach is entered + * w/o locks; this avoids a recursive lock + * of the head and holding sleep locks across + * a (potentially) blocking malloc. + */ + UNP_EXIT(unp); + so3 = sonewconn(so2, 0); + UNP_ENTER(unp); + } else + so3 = 0; + if (so3 == 0) { error = ECONNREFUSED; goto bad; }