From owner-p4-projects@FreeBSD.ORG Tue Aug 11 08:51:23 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 158871065672; Tue, 11 Aug 2009 08:51:23 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C9730106566C for ; Tue, 11 Aug 2009 08:51:22 +0000 (UTC) (envelope-from zhaoshuai@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id AD1DA8FC15 for ; Tue, 11 Aug 2009 08:51:22 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n7B8pMs2089085 for ; Tue, 11 Aug 2009 08:51:22 GMT (envelope-from zhaoshuai@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n7B8pMFP089083 for perforce@freebsd.org; Tue, 11 Aug 2009 08:51:22 GMT (envelope-from zhaoshuai@FreeBSD.org) Date: Tue, 11 Aug 2009 08:51:22 GMT Message-Id: <200908110851.n7B8pMFP089083@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to zhaoshuai@FreeBSD.org using -f From: Zhao Shuai To: Perforce Change Reviews Cc: Subject: PERFORCE change 167203 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Aug 2009 08:51:23 -0000 http://perforce.freebsd.org/chv.cgi?CH=167203 Change 167203 by zhaoshuai@zhaoshuai on 2009/08/11 08:51:05 - add __FBSDID in subr_pipe.c,sys_pipe.c and fifo_vnops.c - re-order pipepair_create() - move funsetown() to the top of pipe_close() Affected files ... .. //depot/projects/soc2009/fifo/sys/fs/fifofs/fifo_vnops.c#20 edit .. //depot/projects/soc2009/fifo/sys/kern/subr_pipe.c#9 edit .. //depot/projects/soc2009/fifo/sys/kern/sys_pipe.c#18 edit Differences ... ==== //depot/projects/soc2009/fifo/sys/fs/fifofs/fifo_vnops.c#20 (text+ko) ==== @@ -32,7 +32,7 @@ * SUCH DAMAGE. * * @(#)fifo_vnops.c 8.10 (Berkeley) 5/27/95 - * + * $FreeBSD: src/sys/fs/fifofs/fifo_vnops.c, XXX */ #include ==== //depot/projects/soc2009/fifo/sys/kern/subr_pipe.c#9 (text+ko) ==== @@ -2,9 +2,6 @@ * Copyright (c) 1996 John S. Dyson * All rights reserved. * - * Copyright (c) 2009 Zhao Shuai - * Google Summer of Code Project - * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -92,6 +89,7 @@ */ #include +__FBSDID("$FreeBSD"); #include "opt_mac.h" @@ -279,6 +277,46 @@ mtx_destroy(&pp->pp_mtx); } +int +pipepair_create(struct thread *td, struct pipe **p_rpipe, struct pipe **p_wpipe) +{ + struct pipepair *pp; + struct pipe *rpipe, *wpipe; + int error; + + pp = uma_zalloc(pipe_zone, M_WAITOK); +#ifdef MAC + /* + * The MAC label is shared between the connected endpoints. As a + * result mac_pipe_init() and mac_pipe_create() are called once + * for the pair, and not on the endpoints. + */ + mac_pipe_init(pp); + mac_pipe_create(td->td_ucred, pp); +#endif + rpipe = &pp->pp_rpipe; + wpipe = &pp->pp_wpipe; + *p_rpipe = rpipe; + *p_wpipe = wpipe; + + knlist_init(&rpipe->pipe_sel.si_note, PIPE_MTX(rpipe), NULL, NULL, + NULL); + knlist_init(&wpipe->pipe_sel.si_note, PIPE_MTX(wpipe), NULL, NULL, + NULL); + + if ((error = pipe_create(rpipe, 1)) != 0 || + (error = pipe_create(wpipe, 0)) != 0) { + pipe_close(rpipe); + pipe_close(wpipe); + return (error); + } + + rpipe->pipe_state |= PIPE_DIRECTOK; + wpipe->pipe_state |= PIPE_DIRECTOK; + + return (0); +} + /* * Allocate kva for pipe circular buffer, the space is pageable * This routine will 'realloc' the size of a pipe safely, if it fails @@ -1325,6 +1363,8 @@ KASSERT(cpipe != NULL, ("pipe_close: cpipe == NULL")); + funsetown(&cpipe->pipe_sigio); + PIPE_LOCK(cpipe); pipelock(cpipe, 0); pp = cpipe->pipe_pair; @@ -1377,9 +1417,6 @@ cpipe->pipe_present = PIPE_FINALIZED; knlist_destroy(&cpipe->pipe_sel.si_note); - /* XXX: is it OK to put it here? */ - funsetown(&cpipe->pipe_sigio); - /* * If both endpoints are now closed, release the memory for the * pipe pair. If not, unlock. @@ -1481,44 +1518,3 @@ PIPE_UNLOCK(rpipe); return (kn->kn_data >= PIPE_BUF); } - -int -pipepair_create(struct thread *td, struct pipe **p_rpipe, struct pipe **p_wpipe) -{ - struct pipepair *pp; - struct pipe *rpipe, *wpipe; - int error; - - pp = uma_zalloc(pipe_zone, M_WAITOK); - rpipe = &pp->pp_rpipe; - wpipe = &pp->pp_wpipe; - *p_rpipe = rpipe; - *p_wpipe = wpipe; - - knlist_init(&rpipe->pipe_sel.si_note, PIPE_MTX(rpipe), NULL, NULL, - NULL); - knlist_init(&wpipe->pipe_sel.si_note, PIPE_MTX(wpipe), NULL, NULL, - NULL); - - if ((error = pipe_create(rpipe, 1)) != 0 || - (error = pipe_create(wpipe, 0)) != 0) { - pipe_close(rpipe); - pipe_close(wpipe); - return (error); - } - - rpipe->pipe_state |= PIPE_DIRECTOK; - wpipe->pipe_state |= PIPE_DIRECTOK; - -#ifdef MAC - /* - * The MAC label is shared between the connected endpoints. As a - * result mac_pipe_init() and mac_pipe_create() are called once - * for the pair, and not on the endpoints. - */ - mac_pipe_init(pp); - mac_pipe_create(td->td_ucred, pp); -#endif - return (0); -} - ==== //depot/projects/soc2009/fifo/sys/kern/sys_pipe.c#18 (text+ko) ==== @@ -26,6 +26,7 @@ */ #include +__FBSDID("$FreeBSD"); #include #include