On 25/01/17(Wed) 19:04, Alexander Bluhm wrote:
> On Wed, Jan 25, 2017 at 11:02:22AM -0500, David Hill wrote:
> > splassert: yield: want 0 have 1
> > Starting stack trace...
> > yield() at yield+0xac
> > pool_get() at pool_get+0x1ca
> > socreate() at socreate+0xba
> > sys_socket() at sys_socket+0x135
> > syscall() at syscall+0x27b
> > --- syscall (number 97) ---
> > end of kernel
> > end trace frame: 0x1b1a16c05800, count: 252
> > 0x1b197d23277a:
> > End of stack trace.
>
> This one looks easy. We do not need a lock to setup the still
> private so structure.
>
> ok?
It's right, in the end what we want is to protect the insertion of the
newly created socket to a global list.
ok mpi@
> Index: kern/uipc_socket.c
> ===================================================================
> RCS file: /cvs/src/sys/kern/uipc_socket.c,v
> retrieving revision 1.173
> diff -u -p -r1.173 uipc_socket.c
> --- kern/uipc_socket.c 25 Jan 2017 16:45:50 -0000 1.173
> +++ kern/uipc_socket.c 25 Jan 2017 18:01:06 -0000
> @@ -123,7 +123,6 @@ socreate(int dom, struct socket **aso, i
> return (EPROTONOSUPPORT);
> if (prp->pr_type != type)
> return (EPROTOTYPE);
> - NET_LOCK(s);
> so = pool_get(&socket_pool, PR_WAITOK | PR_ZERO);
> TAILQ_INIT(&so->so_q0);
> TAILQ_INIT(&so->so_q);
> @@ -136,6 +135,7 @@ socreate(int dom, struct socket **aso, i
> so->so_egid = p->p_ucred->cr_gid;
> so->so_cpid = p->p_p->ps_pid;
> so->so_proto = prp;
> + NET_LOCK(s);
> error = (*prp->pr_usrreq)(so, PRU_ATTACH, NULL,
> (struct mbuf *)(long)proto, NULL, p);
> if (error) {
>