Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/kern/uipc_socket.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/kern/uipc_socket.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.41 retrieving revision 1.44.6.1 diff -u -p -r1.41 -r1.44.6.1 --- src/sys/kern/uipc_socket.c 1999/01/20 09:15:41 1.41 +++ src/sys/kern/uipc_socket.c 1999/06/28 06:36:53 1.44.6.1 @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_socket.c,v 1.41 1999/01/20 09:15:41 mycroft Exp $ */ +/* $NetBSD: uipc_socket.c,v 1.44.6.1 1999/06/28 06:36:53 itojun Exp $ */ /* * Copyright (c) 1982, 1986, 1988, 1990, 1993 @@ -62,6 +62,10 @@ soinit() "sockpl", 0, NULL, NULL, M_SOCKET); } +#ifdef KEY +#include +#endif + /* * Socket operation routines. * These routines are called by the routines in @@ -100,6 +104,8 @@ socreate(dom, aso, type, proto) so->so_proto = prp; so->so_send = sosend; so->so_receive = soreceive; + if (p != 0) + so->so_uid = p->p_ucred->cr_uid; error = (*prp->pr_usrreq)(so, PRU_ATTACH, (struct mbuf *)0, (struct mbuf *)(long)proto, (struct mbuf *)0, p); if (error) { @@ -162,13 +168,27 @@ sofree(so) register struct socket *so; { - /* - * We must not decommission a socket that's on the accept(2) queue. - * If we do, then accept(2) may hang even after select(2) indicated - * that the listening socket was ready. - */ - if (so->so_pcb || so->so_head || (so->so_state & SS_NOFDREF) == 0) + if (so->so_pcb +#ifdef MAPPED_ADDR_ENABLED + /* + * MAPPED_ADDR implementation spec: + * Check so_pcb2 despite the ip6_mapped_addr value. + * Because the sysctl value may be changed to 0 + * after connection establishment. + */ + || so->so_pcb2 +#endif /* MAPPED_ADDR_ENABLED */ + || (so->so_state & SS_NOFDREF) == 0) return; + if (so->so_head) { + /* + * We must not decommission a socket that's on the accept(2) + * queue. If we do, then accept(2) may hang after select(2) + * indicated that the listening socket was ready. + */ + if (!soqremque(so, 0)) + return; + } sbrelease(&so->so_snd); sorflush(so); pool_put(&socket_pool, so); @@ -189,15 +209,19 @@ soclose(so) if (so->so_options & SO_ACCEPTCONN) { while ((so2 = so->so_q0.tqh_first) != 0) { - so2->so_head = 0; + (void) soqremque(so2, 0); (void) soabort(so2); } while ((so2 = so->so_q.tqh_first) != 0) { - so2->so_head = 0; + (void) soqremque(so2, 1); (void) soabort(so2); } } - if (so->so_pcb == 0) + if (so->so_pcb == 0 +#ifdef MAPPED_ADDR_ENABLED + && so->so_pcb2 == 0 +#endif /* MAPPED_ADDR_ENABLED */ + ) goto discard; if (so->so_state & SS_ISCONNECTED) { if ((so->so_state & SS_ISDISCONNECTING) == 0) { @@ -219,7 +243,11 @@ soclose(so) } } drop: - if (so->so_pcb) { + if (so->so_pcb +#ifdef MAPPED_ADDR_ENABLED + || so->so_pcb2 +#endif /* MAPPED_ADDR_ENABLED */ + ) { int error2 = (*so->so_proto->pr_usrreq)(so, PRU_DETACH, (struct mbuf *)0, (struct mbuf *)0, (struct mbuf *)0, (struct proc *)0); @@ -816,7 +844,13 @@ dontblock: if ((flags & MSG_PEEK) == 0) { if (m == 0) so->so_rcv.sb_mb = nextrecord; - if (pr->pr_flags & PR_WANTRCVD && so->so_pcb) + if (pr->pr_flags & PR_WANTRCVD && + (so->so_pcb +#ifdef MAPPED_ADDR_ENABLED + || so->so_pcb2 +#endif /* MAPPED_ADDR_ENABLED */ + ) + ) (*pr->pr_usrreq)(so, PRU_RCVD, (struct mbuf *)0, (struct mbuf *)(long)flags, (struct mbuf *)0, (struct proc *)0);