From owner-p4-projects@FreeBSD.ORG Tue Dec 9 15:08:35 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id C3C6516A4D0; Tue, 9 Dec 2003 15:08:34 -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 9DE7C16A4CE for ; Tue, 9 Dec 2003 15:08:34 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id A083743D09 for ; Tue, 9 Dec 2003 15:08:33 -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 hB9N8XXJ034333 for ; Tue, 9 Dec 2003 15:08:33 -0800 (PST) (envelope-from sam@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.9/8.12.9/Submit) id hB9N8XoP034330 for perforce@freebsd.org; Tue, 9 Dec 2003 15:08:33 -0800 (PST) (envelope-from sam@freebsd.org) Date: Tue, 9 Dec 2003 15:08:33 -0800 (PST) Message-Id: <200312092308.hB9N8XoP034330@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 43697 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: Tue, 09 Dec 2003 23:08:35 -0000 http://perforce.freebsd.org/chv.cgi?CH=43697 Change 43697 by sam@sam_ebb on 2003/12/09 15:07:39 o IFC o mark unp mutex DUPOK because we can't distinguish between multiple unp's in connect2 case and so get spurious complaints (need better solution) o add more socket locking o lock unpcb's when emptying ref list on detach to conform to locking rules Affected files ... .. //depot/projects/netperf+sockets/sys/kern/uipc_usrreq.c#3 edit Differences ... ==== //depot/projects/netperf+sockets/sys/kern/uipc_usrreq.c#3 (text+ko) ==== @@ -34,7 +34,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/kern/uipc_usrreq.c,v 1.111 2003/06/11 00:56:58 obrien Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/uipc_usrreq.c,v 1.112 2003/11/18 00:39:03 rwatson Exp $"); #include "opt_mac.h" @@ -92,8 +92,9 @@ #define UNP_HEAD_UNLOCK() mtx_unlock(&unp_mtx) #define UNP_HEAD_LOCK_ASSERT() mtx_assert(&unp_mtx, MA_OWNED) +/* NB: DUPOK is to cover the connect2 case XXX */ #define UNP_LOCK_INIT(_unp) \ - mtx_init(&(_unp)->unp_mtx, "unp", NULL, MTX_DEF) + mtx_init(&(_unp)->unp_mtx, "unp", NULL, MTX_DEF | MTX_DUPOK) #define UNP_LOCK_DESTROY(_unp) mtx_destroy(&(_unp)->unp_mtx) #define UNP_LOCK(_unp) mtx_lock(&(_unp)->unp_mtx) #define UNP_UNLOCK(_unp) mtx_unlock(&(_unp)->unp_mtx) @@ -142,6 +143,7 @@ UNP_ENTER(unp); unp_drop(unp, ECONNABORTED); unp_detach(unp); /* NB: unlocks unp + head */ + SOCK_LOCK(so); sotryfree(so); return 0; } @@ -536,7 +538,7 @@ uipc_connect2, pru_control_notsupp, uipc_detach, uipc_disconnect, uipc_listen, uipc_peeraddr, uipc_rcvd, pru_rcvoob_notsupp, uipc_send, uipc_sense, uipc_shutdown, uipc_sockaddr, - sosend, soreceive, sopoll + sosend, soreceive, sopoll, pru_sosetlabel_null }; int @@ -667,8 +669,12 @@ } if (unp->unp_conn) unp_disconnect(unp); - while (!LIST_EMPTY(&unp->unp_refs)) - unp_drop(LIST_FIRST(&unp->unp_refs), ECONNRESET); + while (!LIST_EMPTY(&unp->unp_refs)) { + struct unpcb *ref = LIST_FIRST(&unp->unp_refs); + UNP_LOCK(ref); + unp_drop(ref, ECONNRESET); + UNP_UNLOCK(ref); + } soisdisconnected(unp->unp_socket); unp->unp_socket->so_pcb = 0; if (unp_rights) {