This makes witness(4) use a single lock type for tracking so_lock.
Previously, so_lock was covered by two distinct lock types because there
were separate rw_init() initializers in socreate() and sonewconn().
OK kettenis@
-/* $OpenBSD: uipc_socket.c,v 1.267 2021/10/24 07:02:47 visa Exp $ */
+/* $OpenBSD: uipc_socket.c,v 1.268 2021/11/06 05:26:33 visa Exp $ */
/* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */
/*
#endif
}
+struct socket *
+soalloc(int prflags)
+{
+ struct socket *so;
+
+ so = pool_get(&socket_pool, prflags);
+ if (so == NULL)
+ return (NULL);
+ rw_init(&so->so_lock, "solock");
+ return (so);
+}
+
/*
* Socket operation routines.
* These routines are called by the routines in
return (EPROTONOSUPPORT);
if (prp->pr_type != type)
return (EPROTOTYPE);
- so = pool_get(&socket_pool, PR_WAITOK | PR_ZERO);
- rw_init(&so->so_lock, "solock");
+ so = soalloc(PR_WAITOK | PR_ZERO);
klist_init(&so->so_rcv.sb_sel.si_note, &socket_klistops, so);
klist_init(&so->so_snd.sb_sel.si_note, &socket_klistops, so);
sigio_init(&so->so_sigio);
-/* $OpenBSD: uipc_socket2.c,v 1.115 2021/10/27 13:41:09 mvs Exp $ */
+/* $OpenBSD: uipc_socket2.c,v 1.116 2021/11/06 05:26:33 visa Exp $ */
/* $NetBSD: uipc_socket2.c,v 1.11 1996/02/04 02:17:55 christos Exp $ */
/*
return (NULL);
if (head->so_qlen + head->so_q0len > head->so_qlimit * 3)
return (NULL);
- so = pool_get(&socket_pool, PR_NOWAIT|PR_ZERO);
+ so = soalloc(PR_NOWAIT | PR_ZERO);
if (so == NULL)
return (NULL);
- rw_init(&so->so_lock, "solock");
so->so_type = head->so_type;
so->so_options = head->so_options &~ SO_ACCEPTCONN;
so->so_linger = head->so_linger;
-/* $OpenBSD: socketvar.h,v 1.100 2021/07/26 05:51:13 mpi Exp $ */
+/* $OpenBSD: socketvar.h,v 1.101 2021/11/06 05:26:33 visa Exp $ */
/* $NetBSD: socketvar.h,v 1.18 1996/02/09 18:25:38 christos Exp $ */
/*-
int soconnect2(struct socket *, struct socket *);
int socreate(int, struct socket **, int, int);
int sodisconnect(struct socket *);
+struct socket *soalloc(int);
void sofree(struct socket *, int);
int sogetopt(struct socket *, int, int, struct mbuf *);
void sohasoutofband(struct socket *);