-/* $OpenBSD: uipc_socket.c,v 1.299 2023/01/27 21:01:59 mvs Exp $ */
+/* $OpenBSD: uipc_socket.c,v 1.300 2023/02/02 09:35:07 mvs Exp $ */
/* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */
/*
.f_process = filt_soprocess,
};
+void klist_soassertlk(void *);
+int klist_solock(void *);
+void klist_sounlock(void *, int);
+
+const struct klistops socket_klistops = {
+ .klo_assertlk = klist_soassertlk,
+ .klo_lock = klist_solock,
+ .klo_unlock = klist_sounlock,
+};
+
#ifndef SOMINCONN
#define SOMINCONN 80
#endif /* SOMINCONN */
return (NULL);
rw_init_flags(&so->so_lock, "solock", RWL_DUPOK);
refcnt_init(&so->so_refcnt);
+ klist_init(&so->so_rcv.sb_klist, &socket_klistops, so);
+ klist_init(&so->so_snd.sb_klist, &socket_klistops, so);
+ sigio_init(&so->so_sigio);
+ TAILQ_INIT(&so->so_q0);
+ TAILQ_INIT(&so->so_q);
return (so);
}
if (prp->pr_type != type)
return (EPROTOTYPE);
so = soalloc(M_WAIT);
- klist_init(&so->so_rcv.sb_klist, &socket_klistops, so);
- klist_init(&so->so_snd.sb_klist, &socket_klistops, so);
- sigio_init(&so->so_sigio);
- TAILQ_INIT(&so->so_q0);
- TAILQ_INIT(&so->so_q);
so->so_type = type;
if (suser(p) == 0)
so->so_state = SS_PRIV;
sounlock(so);
}
-const struct klistops socket_klistops = {
- .klo_assertlk = klist_soassertlk,
- .klo_lock = klist_solock,
- .klo_unlock = klist_sounlock,
-};
-
#ifdef DDB
void
sobuf_print(struct sockbuf *,
-/* $OpenBSD: uipc_socket2.c,v 1.134 2023/01/27 18:46:34 mvs Exp $ */
+/* $OpenBSD: uipc_socket2.c,v 1.135 2023/02/02 09:35:07 mvs Exp $ */
/* $NetBSD: uipc_socket2.c,v 1.11 1996/02/04 02:17:55 christos Exp $ */
/*
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/signalvar.h>
-#include <sys/event.h>
#include <sys/pool.h>
/*
/*
* Inherit watermarks but those may get clamped in low mem situations.
*/
- if (soreserve(so, head->so_snd.sb_hiwat, head->so_rcv.sb_hiwat)) {
- if (persocket)
- sounlock(so);
- pool_put(&socket_pool, so);
- return (NULL);
- }
+ if (soreserve(so, head->so_snd.sb_hiwat, head->so_rcv.sb_hiwat))
+ goto fail;
so->so_snd.sb_wat = head->so_snd.sb_wat;
so->so_snd.sb_lowat = head->so_snd.sb_lowat;
so->so_snd.sb_timeo_nsecs = head->so_snd.sb_timeo_nsecs;
so->so_rcv.sb_lowat = head->so_rcv.sb_lowat;
so->so_rcv.sb_timeo_nsecs = head->so_rcv.sb_timeo_nsecs;
- klist_init(&so->so_rcv.sb_klist, &socket_klistops, so);
- klist_init(&so->so_snd.sb_klist, &socket_klistops, so);
- sigio_init(&so->so_sigio);
sigio_copy(&so->so_sigio, &head->so_sigio);
soqinsque(head, so, 0);
if (error) {
soqremque(so, 0);
- if (persocket)
- sounlock(so);
- sigio_free(&so->so_sigio);
- klist_free(&so->so_rcv.sb_klist);
- klist_free(&so->so_snd.sb_klist);
- pool_put(&socket_pool, so);
- return (NULL);
+ goto fail;
}
if (connstatus) {
sounlock(so);
return (so);
+
+fail:
+ if (persocket)
+ sounlock(so);
+ sigio_free(&so->so_sigio);
+ klist_free(&so->so_rcv.sb_klist);
+ klist_free(&so->so_snd.sb_klist);
+ pool_put(&socket_pool, so);
+
+ return (NULL);
}
void
-/* $OpenBSD: event.h,v 1.67 2022/03/31 01:41:22 millert Exp $ */
+/* $OpenBSD: event.h,v 1.68 2023/02/02 09:35:07 mvs Exp $ */
/*-
* Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org>
extern const struct filterops sig_filtops;
extern const struct filterops dead_filtops;
-extern const struct klistops socket_klistops;
extern void kqpoll_init(unsigned int);
extern void kqpoll_done(unsigned int);