per-socket locking.
No functional change.
-/* $OpenBSD: uipc_socket.c,v 1.263 2021/05/28 16:24:53 visa Exp $ */
+/* $OpenBSD: uipc_socket.c,v 1.264 2021/07/26 05:51:13 mpi Exp $ */
/* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */
/*
*paddr = m_copym(m, 0, m->m_len, M_NOWAIT);
m = m->m_next;
} else {
- sbfree(&so->so_rcv, m);
+ sbfree(so, &so->so_rcv, m);
if (paddr) {
*paddr = m;
so->so_rcv.sb_mb = m->m_next;
*controlp = m_copym(m, 0, m->m_len, M_NOWAIT);
m = m->m_next;
} else {
- sbfree(&so->so_rcv, m);
+ sbfree(so, &so->so_rcv, m);
so->so_rcv.sb_mb = m->m_next;
m->m_nextpkt = m->m_next = NULL;
cm = m;
orig_resid = 0;
} else {
nextrecord = m->m_nextpkt;
- sbfree(&so->so_rcv, m);
+ sbfree(so, &so->so_rcv, m);
if (mp) {
*mp = m;
mp = &m->m_next;
if (m && pr->pr_flags & PR_ATOMIC) {
flags |= MSG_TRUNC;
if ((flags & MSG_PEEK) == 0)
- (void) sbdroprecord(&so->so_rcv);
+ (void) sbdroprecord(so, &so->so_rcv);
}
if ((flags & MSG_PEEK) == 0) {
if (m == NULL) {
while (m && m->m_type == MT_CONTROL)
m = m->m_next;
if (m == NULL) {
- sbdroprecord(&so->so_rcv);
+ sbdroprecord(so, &so->so_rcv);
if (so->so_proto->pr_flags & PR_WANTRCVD && so->so_pcb)
(so->so_proto->pr_usrreq)(so, PRU_RCVD, NULL,
NULL, NULL, NULL);
* that the whole first record can be processed.
*/
m = so->so_rcv.sb_mb;
- sbfree(&so->so_rcv, m);
+ sbfree(so, &so->so_rcv, m);
so->so_rcv.sb_mb = m_free(m);
sbsync(&so->so_rcv, nextrecord);
}
*/
m = so->so_rcv.sb_mb;
while (m && m->m_type == MT_CONTROL) {
- sbfree(&so->so_rcv, m);
+ sbfree(so, &so->so_rcv, m);
so->so_rcv.sb_mb = m_free(m);
m = so->so_rcv.sb_mb;
sbsync(&so->so_rcv, nextrecord);
so->so_rcv.sb_datacc -= size;
} else {
*mp = so->so_rcv.sb_mb;
- sbfree(&so->so_rcv, *mp);
+ sbfree(so, &so->so_rcv, *mp);
so->so_rcv.sb_mb = (*mp)->m_next;
sbsync(&so->so_rcv, nextrecord);
}
SBLASTRECORDCHK(&so->so_rcv, "somove 3");
SBLASTMBUFCHK(&so->so_rcv, "somove 3");
- SBCHECK(&so->so_rcv);
+ SBCHECK(so, &so->so_rcv);
if (m == NULL)
goto release;
m->m_nextpkt = NULL;
-/* $OpenBSD: uipc_socket2.c,v 1.112 2021/07/25 14:13:47 mpi Exp $ */
+/* $OpenBSD: uipc_socket2.c,v 1.113 2021/07/26 05:51:13 mpi Exp $ */
/* $NetBSD: uipc_socket2.c,v 1.11 1996/02/04 02:17:55 christos Exp $ */
/*
*/
sb->sb_lastrecord = m;
}
- sbcompress(sb, m, n);
+ sbcompress(so, sb, m, n);
SBLASTRECORDCHK(sb, "sbappend 2");
}
SBLASTMBUFCHK(sb, __func__);
- sbcompress(sb, m, sb->sb_mbtail);
+ sbcompress(so, sb, m, sb->sb_mbtail);
sb->sb_lastrecord = sb->sb_mb;
SBLASTRECORDCHK(sb, __func__);
#ifdef SOCKBUF_DEBUG
void
-sbcheck(struct sockbuf *sb)
+sbcheck(struct socket *so, struct sockbuf *sb)
{
struct mbuf *m, *n;
u_long len = 0, mbcnt = 0;
* Put the first mbuf on the queue.
* Note this permits zero length records.
*/
- sballoc(sb, m0);
+ sballoc(so, sb, m0);
SBLASTRECORDCHK(sb, "sbappendrecord 1");
SBLINKRECORD(sb, m0);
m = m0->m_next;
m0->m_flags &= ~M_EOR;
m->m_flags |= M_EOR;
}
- sbcompress(sb, m, m0);
+ sbcompress(so, sb, m, m0);
SBLASTRECORDCHK(sb, "sbappendrecord 2");
}
SBLASTRECORDCHK(sb, "sbappendaddr 1");
for (n = m; n->m_next != NULL; n = n->m_next)
- sballoc(sb, n);
- sballoc(sb, n);
+ sballoc(so, sb, n);
+ sballoc(so, sb, n);
nlast = n;
SBLINKRECORD(sb, m);
SBLASTRECORDCHK(sb, "sbappendcontrol 1");
for (m = control; m->m_next != NULL; m = m->m_next)
- sballoc(sb, m);
- sballoc(sb, m);
+ sballoc(so, sb, m);
+ sballoc(so, sb, m);
mlast = m;
SBLINKRECORD(sb, control);
* is null, the buffer is presumed empty.
*/
void
-sbcompress(struct sockbuf *sb, struct mbuf *m, struct mbuf *n)
+sbcompress(struct socket *so, struct sockbuf *sb, struct mbuf *m,
+ struct mbuf *n)
{
int eor = 0;
struct mbuf *o;
else
sb->sb_mb = m;
sb->sb_mbtail = m;
- sballoc(sb, m);
+ sballoc(so, sb, m);
n = m;
m->m_flags &= ~M_EOR;
m = m->m_next;
break;
}
len -= m->m_len;
- sbfree(sb, m);
+ sbfree(so, sb, m);
mn = m_free(m);
m = mn;
}
while (m && m->m_len == 0) {
- sbfree(sb, m);
+ sbfree(so, sb, m);
mn = m_free(m);
m = mn;
}
* and move the next record to the front.
*/
void
-sbdroprecord(struct sockbuf *sb)
+sbdroprecord(struct socket *so, struct sockbuf *sb)
{
struct mbuf *m, *mn;
if (m) {
sb->sb_mb = m->m_nextpkt;
do {
- sbfree(sb, m);
+ sbfree(so, sb, m);
mn = m_free(m);
} while ((m = mn) != NULL);
}
-/* $OpenBSD: socketvar.h,v 1.99 2021/07/25 14:13:47 mpi Exp $ */
+/* $OpenBSD: socketvar.h,v 1.100 2021/07/26 05:51:13 mpi Exp $ */
/* $NetBSD: socketvar.h,v 1.18 1996/02/09 18:25:38 christos Exp $ */
/*-
((so)->so_state & SS_CANTSENDMORE) || (so)->so_error)
/* adjust counters in sb reflecting allocation of m */
-#define sballoc(sb, m) do { \
+#define sballoc(so, sb, m) do { \
(sb)->sb_cc += (m)->m_len; \
if ((m)->m_type != MT_CONTROL && (m)->m_type != MT_SONAME) \
(sb)->sb_datacc += (m)->m_len; \
} while (/* CONSTCOND */ 0)
/* adjust counters in sb reflecting freeing of m */
-#define sbfree(sb, m) do { \
+#define sbfree(so, sb, m) do { \
(sb)->sb_cc -= (m)->m_len; \
if ((m)->m_type != MT_CONTROL && (m)->m_type != MT_SONAME) \
(sb)->sb_datacc -= (m)->m_len; \
int sbappendcontrol(struct socket *, struct sockbuf *, struct mbuf *,
struct mbuf *);
void sbappendrecord(struct socket *, struct sockbuf *, struct mbuf *);
-void sbcompress(struct sockbuf *, struct mbuf *, struct mbuf *);
+void sbcompress(struct socket *, struct sockbuf *, struct mbuf *,
+ struct mbuf *);
struct mbuf *
sbcreatecontrol(const void *, size_t, int, int);
void sbdrop(struct socket *, struct sockbuf *, int);
-void sbdroprecord(struct sockbuf *);
+void sbdroprecord(struct socket *, struct sockbuf *);
void sbflush(struct socket *, struct sockbuf *);
void sbrelease(struct socket *, struct sockbuf *);
int sbcheckreserve(u_long, u_long);
void sblastmbufchk(struct sockbuf *, const char *);
#define SBLASTMBUFCHK(sb, where) sblastmbufchk((sb), (where))
-void sbcheck(struct sockbuf *);
-#define SBCHECK(sb) sbcheck(sb)
+void sbcheck(struct socket *, struct sockbuf *);
+#define SBCHECK(so, sb) sbcheck((so), (sb))
#else
#define SBLASTRECORDCHK(sb, where) /* nothing */
#define SBLASTMBUFCHK(sb, where) /* nothing */
-#define SBCHECK(sb) /* nothing */
+#define SBCHECK(so, sb) /* nothing */
#endif /* SOCKBUF_DEBUG */
#endif /* _KERNEL */