Date: Tue, 9 Dec 2003 15:08:33 -0800 (PST) From: Sam Leffler <sam@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 43697 for review Message-ID: <200312092308.hB9N8XoP034330@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 <sys/cdefs.h> -__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) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200312092308.hB9N8XoP034330>