Deleted Added
sdiff udiff text old ( 35413 ) new ( 36079 )
full compact
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_socket2.c 8.1 (Berkeley) 6/10/93
34 * $Id: uipc_socket2.c,v 1.32 1998/04/04 13:25:40 phk Exp $
35 */
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/kernel.h>
40#include <sys/proc.h>
41#include <sys/malloc.h>
42#include <sys/mbuf.h>
43#include <sys/protosw.h>
44#include <sys/stat.h>
45#include <sys/socket.h>
46#include <sys/socketvar.h>

--- 150 unchanged lines hidden (view full) ---

197sonewconn(head, connstatus)
198 register struct socket *head;
199 int connstatus;
200{
201 register struct socket *so;
202
203 if (head->so_qlen > 3 * head->so_qlimit / 2)
204 return ((struct socket *)0);
205 MALLOC(so, struct socket *, sizeof(*so), M_SOCKET, M_DONTWAIT);
206 if (so == NULL)
207 return ((struct socket *)0);
208 bzero((caddr_t)so, sizeof(*so));
209 so->so_head = head;
210 so->so_type = head->so_type;
211 so->so_options = head->so_options &~ SO_ACCEPTCONN;
212 so->so_linger = head->so_linger;
213 so->so_state = head->so_state | SS_NOFDREF;
214 so->so_proto = head->so_proto;
215 so->so_timeo = head->so_timeo;
216 so->so_pgid = head->so_pgid;
217 so->so_uid = head->so_uid;
218 (void) soreserve(so, head->so_snd.sb_hiwat, head->so_rcv.sb_hiwat);
219
220 if ((*so->so_proto->pr_usrreqs->pru_attach)(so, 0, NULL)) {
221 (void) free((caddr_t)so, M_SOCKET);
222 return ((struct socket *)0);
223 }
224
225 if (connstatus) {
226 TAILQ_INSERT_TAIL(&head->so_comp, so, so_list);
227 so->so_state |= SS_COMP;
228 } else {
229 TAILQ_INSERT_TAIL(&head->so_incomp, so, so_list);

--- 655 unchanged lines hidden (view full) ---

885 MALLOC(sa2, struct sockaddr *, sa->sa_len, M_SONAME,
886 canwait ? M_WAITOK : M_NOWAIT);
887 if (sa2)
888 bcopy(sa, sa2, sa->sa_len);
889 return sa2;
890}
891
892/*
893 * Here is the definition of some of the basic objects in the kern.ipc
894 * branch of the MIB.
895 */
896SYSCTL_NODE(_kern, KERN_IPC, ipc, CTLFLAG_RW, 0, "IPC");
897
898/* This takes the place of kern.maxsockbuf, which moved to kern.ipc. */
899static int dummy;
900SYSCTL_INT(_kern, KERN_DUMMY, dummy, CTLFLAG_RW, &dummy, 0, "");
901
902SYSCTL_INT(_kern_ipc, KIPC_MAXSOCKBUF, maxsockbuf, CTLFLAG_RW, &sb_max, 0, "");
903SYSCTL_INT(_kern_ipc, KIPC_SOCKBUF_WASTE, sockbuf_waste_factor, CTLFLAG_RW,
904 &sb_efficiency, 0, "");
905SYSCTL_INT(_kern_ipc, KIPC_NMBCLUSTERS, nmbclusters, CTLFLAG_RD, &nmbclusters, 0, "");
906