Date: Tue, 11 Aug 2009 08:51:22 GMT From: Zhao Shuai <zhaoshuai@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 167203 for review Message-ID: <200908110851.n7B8pMFP089083@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 <sys/param.h> ==== //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 <zhaoshuai@FreeBSD.org> - * 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 <sys/cdefs.h> +__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 <sys/cdefs.h> +__FBSDID("$FreeBSD"); #include <sys/param.h> #include <sys/systm.h>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200908110851.n7B8pMFP089083>