uipc_socket.c (101983) | uipc_socket.c (104541) |
---|---|
1/* 2 * Copyright (c) 1982, 1986, 1988, 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)uipc_socket.c 8.3 (Berkeley) 4/15/94 | 1/* 2 * Copyright (c) 1982, 1986, 1988, 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)uipc_socket.c 8.3 (Berkeley) 4/15/94 |
34 * $FreeBSD: head/sys/kern/uipc_socket.c 101983 2002-08-16 12:52:03Z rwatson $ | 34 * $FreeBSD: head/sys/kern/uipc_socket.c 104541 2002-10-05 21:23:47Z rwatson $ |
35 */ 36 37#include "opt_inet.h" 38#include "opt_mac.h" 39#include "opt_zero.h" 40 41#include <sys/param.h> 42#include <sys/systm.h> --- 83 unchanged lines hidden (view full) --- 126 * 127 * soalloc() returns a socket with a ref count of 0. 128 */ 129struct socket * 130soalloc(waitok) 131 int waitok; 132{ 133 struct socket *so; | 35 */ 36 37#include "opt_inet.h" 38#include "opt_mac.h" 39#include "opt_zero.h" 40 41#include <sys/param.h> 42#include <sys/systm.h> --- 83 unchanged lines hidden (view full) --- 126 * 127 * soalloc() returns a socket with a ref count of 0. 128 */ 129struct socket * 130soalloc(waitok) 131 int waitok; 132{ 133 struct socket *so; |
134#ifdef MAC 135 int error; 136#endif |
|
134 int flag; 135 136 if (waitok == 1) 137 flag = M_WAITOK; 138 else 139 flag = M_NOWAIT; 140 flag |= M_ZERO; 141 so = uma_zalloc(socket_zone, flag); 142 if (so) { | 137 int flag; 138 139 if (waitok == 1) 140 flag = M_WAITOK; 141 else 142 flag = M_NOWAIT; 143 flag |= M_ZERO; 144 so = uma_zalloc(socket_zone, flag); 145 if (so) { |
146#ifdef MAC 147 error = mac_init_socket(so, flag); 148 if (error != 0) { 149 uma_zfree(socket_zone, so); 150 so = NULL; 151 return so; 152 } 153#endif |
|
143 /* XXX race condition for reentrant kernel */ 144 so->so_gencnt = ++so_gencnt; 145 /* sx_init(&so->so_sxlock, "socket sxlock"); */ 146 TAILQ_INIT(&so->so_aiojobq); 147 ++numopensockets; | 154 /* XXX race condition for reentrant kernel */ 155 so->so_gencnt = ++so_gencnt; 156 /* sx_init(&so->so_sxlock, "socket sxlock"); */ 157 TAILQ_INIT(&so->so_aiojobq); 158 ++numopensockets; |
148#ifdef MAC 149 mac_init_socket(so); 150#endif | |
151 } 152 return so; 153} 154 155/* 156 * socreate returns a socket with a ref count of 1. The socket should be 157 * closed with soclose(). 158 */ --- 1687 unchanged lines hidden --- | 159 } 160 return so; 161} 162 163/* 164 * socreate returns a socket with a ref count of 1. The socket should be 165 * closed with soclose(). 166 */ --- 1687 unchanged lines hidden --- |