On Wed, Aug 09, 2017 at 07:34:51PM -0400, Martin Pieuchot wrote:
> Diff below move solock()/sounlock() outside of sobind().  It's the
> next logical step to merge all the lock/unlock dances in nfs_connect().
> 
> ok?

OK bluhm@

> Index: kern/uipc_socket.c
> ===================================================================
> RCS file: /cvs/src/sys/kern/uipc_socket.c,v
> retrieving revision 1.199
> diff -u -p -r1.199 uipc_socket.c
> --- kern/uipc_socket.c        9 Aug 2017 14:22:58 -0000       1.199
> +++ kern/uipc_socket.c        9 Aug 2017 23:31:24 -0000
> @@ -152,11 +152,11 @@ socreate(int dom, struct socket **aso, i
>  int
>  sobind(struct socket *so, struct mbuf *nam, struct proc *p)
>  {
> -     int s, error;
> +     int error;
> +
> +     soassertlocked(so);
>  
> -     s = solock(so);
>       error = (*so->so_proto->pr_usrreq)(so, PRU_BIND, NULL, nam, NULL, p);
> -     sounlock(s);
>       return (error);
>  }
>  
> Index: kern/uipc_syscalls.c
> ===================================================================
> RCS file: /cvs/src/sys/kern/uipc_syscalls.c,v
> retrieving revision 1.157
> diff -u -p -r1.157 uipc_syscalls.c
> --- kern/uipc_syscalls.c      9 Aug 2017 14:22:58 -0000       1.157
> +++ kern/uipc_syscalls.c      9 Aug 2017 23:31:24 -0000
> @@ -184,7 +184,7 @@ sys_bind(struct proc *p, void *v, regist
>       struct file *fp;
>       struct mbuf *nam;
>       struct socket *so;
> -     int error;
> +     int s, error;
>  
>       if ((error = getsock(p, SCARG(uap, s), &fp)) != 0)
>               return (error);
> @@ -201,7 +201,9 @@ sys_bind(struct proc *p, void *v, regist
>       if (KTRPOINT(p, KTR_STRUCT))
>               ktrsockaddr(p, mtod(nam, caddr_t), SCARG(uap, namelen));
>  #endif
> +     s = solock(so);
>       error = sobind(so, nam, p);
> +     sounlock(s);
>       m_freem(nam);
>  out:
>       FRELE(fp, p);
> Index: net/if_pflow.c
> ===================================================================
> RCS file: /cvs/src/sys/net/if_pflow.c,v
> retrieving revision 1.80
> diff -u -p -r1.80 if_pflow.c
> --- net/if_pflow.c    31 May 2017 13:05:43 -0000      1.80
> +++ net/if_pflow.c    9 Aug 2017 23:31:24 -0000
> @@ -438,6 +438,7 @@ pflow_set(struct pflow_softc *sc, struct
>                               return (error);
>                       if (pflowvalidsockaddr(sc->sc_flowsrc, 1)) {
>                               struct mbuf *m;
> +                             int s;
>  
>                               MGET(m, M_WAIT, MT_SONAME);
>                               m->m_len = sc->sc_flowsrc->sa_len;
> @@ -445,7 +446,9 @@ pflow_set(struct pflow_softc *sc, struct
>                               memcpy(sa, sc->sc_flowsrc,
>                                   sc->sc_flowsrc->sa_len);
>  
> +                             s = solock(so);
>                               error = sobind(so, m, p);
> +                             sounlock(s);
>                               m_freem(m);
>                               if (error) {
>                                       soclose(so);
> Index: nfs/krpc_subr.c
> ===================================================================
> RCS file: /cvs/src/sys/nfs/krpc_subr.c,v
> retrieving revision 1.30
> diff -u -p -r1.30 krpc_subr.c
> --- nfs/krpc_subr.c   9 Aug 2017 14:22:58 -0000       1.30
> +++ nfs/krpc_subr.c   9 Aug 2017 23:31:24 -0000
> @@ -283,7 +283,9 @@ krpc_call(struct sockaddr_in *sa, u_int 
>       sin->sin_family = AF_INET;
>       sin->sin_addr.s_addr = INADDR_ANY;
>       sin->sin_port = htons(0);
> +     s = solock(so);
>       error = sobind(so, m, &proc0);
> +     sounlock(s);
>       m_freem(m);
>       if (error) {
>               printf("bind failed\n");
> Index: nfs/nfs_socket.c
> ===================================================================
> RCS file: /cvs/src/sys/nfs/nfs_socket.c,v
> retrieving revision 1.121
> diff -u -p -r1.121 nfs_socket.c
> --- nfs/nfs_socket.c  9 Aug 2017 14:22:58 -0000       1.121
> +++ nfs/nfs_socket.c  9 Aug 2017 23:31:24 -0000
> @@ -275,7 +275,9 @@ nfs_connect(struct nfsmount *nmp, struct
>               sin->sin_family = AF_INET;
>               sin->sin_addr.s_addr = INADDR_ANY;
>               sin->sin_port = htons(0);
> +             s = solock(so);
>               error = sobind(so, m, &proc0);
> +             sounlock(s);
>               m_freem(m);
>               if (error)
>                       goto bad;

Reply via email to