git: a10021748940 - main - Consistently use the SOCKBUF_MTX() and SOCK_MTX() macros
Mark Johnston
markj at FreeBSD.org
Mon Jun 14 21:34:39 UTC 2021
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=a100217489405e5926230c50d97aa3f886df5385
commit a100217489405e5926230c50d97aa3f886df5385
Author: Mark Johnston <markj at FreeBSD.org>
AuthorDate: 2021-06-14 21:32:32 +0000
Commit: Mark Johnston <markj at FreeBSD.org>
CommitDate: 2021-06-14 21:32:32 +0000
Consistently use the SOCKBUF_MTX() and SOCK_MTX() macros
This makes it easier to change the socket locking protocols. No
functional change intended.
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
---
sys/dev/iscsi/icl_soft.c | 2 +-
sys/kern/uipc_sockbuf.c | 2 +-
sys/kern/uipc_socket.c | 2 +-
sys/netinet/sctputil.c | 6 +++---
sys/sys/socketvar.h | 2 +-
5 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/sys/dev/iscsi/icl_soft.c b/sys/dev/iscsi/icl_soft.c
index c15afbb59a68..001c595af7ec 100644
--- a/sys/dev/iscsi/icl_soft.c
+++ b/sys/dev/iscsi/icl_soft.c
@@ -729,7 +729,7 @@ icl_receive_thread(void *arg)
available = sbavail(&so->so_rcv);
if (read + available < ic->ic_receive_len) {
so->so_rcv.sb_lowat = ic->ic_receive_len - read;
- cv_wait(&ic->ic_receive_cv, &so->so_rcv.sb_mtx);
+ cv_wait(&ic->ic_receive_cv, SOCKBUF_MTX(&so->so_rcv));
so->so_rcv.sb_lowat = so->so_rcv.sb_hiwat + 1;
available = sbavail(&so->so_rcv);
}
diff --git a/sys/kern/uipc_sockbuf.c b/sys/kern/uipc_sockbuf.c
index cf53f234d8fc..2c0e10ee1dc2 100644
--- a/sys/kern/uipc_sockbuf.c
+++ b/sys/kern/uipc_sockbuf.c
@@ -446,7 +446,7 @@ sbwait(struct sockbuf *sb)
SOCKBUF_LOCK_ASSERT(sb);
sb->sb_flags |= SB_WAIT;
- return (msleep_sbt(&sb->sb_acc, &sb->sb_mtx,
+ return (msleep_sbt(&sb->sb_acc, SOCKBUF_MTX(sb),
(sb->sb_flags & SB_NOINTR) ? PSOCK : PSOCK | PCATCH, "sbwait",
sb->sb_timeo, 0, 0));
}
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index 46d9cb8f3a90..ee3374137acd 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -1015,7 +1015,7 @@ solisten_dequeue(struct socket *head, struct socket **ret, int flags)
while (!(head->so_state & SS_NBIO) && TAILQ_EMPTY(&head->sol_comp) &&
head->so_error == 0) {
- error = msleep(&head->sol_comp, &head->so_lock, PSOCK | PCATCH,
+ error = msleep(&head->sol_comp, SOCK_MTX(head), PSOCK | PCATCH,
"accept", 0);
if (error != 0) {
SOLISTEN_UNLOCK(head);
diff --git a/sys/netinet/sctputil.c b/sys/netinet/sctputil.c
index 2c10ab158c83..82fc38b39ff7 100644
--- a/sys/netinet/sctputil.c
+++ b/sys/netinet/sctputil.c
@@ -376,9 +376,9 @@ sctp_log_lock(struct sctp_inpcb *inp, struct sctp_tcb *stcb, uint8_t from)
}
sctp_clog.x.lock.info_lock = rw_wowned(&SCTP_BASE_INFO(ipi_ep_mtx));
if (inp && (inp->sctp_socket)) {
- sctp_clog.x.lock.sock_lock = mtx_owned(&(inp->sctp_socket->so_rcv.sb_mtx));
- sctp_clog.x.lock.sockrcvbuf_lock = mtx_owned(&(inp->sctp_socket->so_rcv.sb_mtx));
- sctp_clog.x.lock.socksndbuf_lock = mtx_owned(&(inp->sctp_socket->so_snd.sb_mtx));
+ sctp_clog.x.lock.sock_lock = mtx_owned(SOCK_MTX(inp->sctp_socket));
+ sctp_clog.x.lock.sockrcvbuf_lock = mtx_owned(SOCKBUF_MTX(&inp->sctp_socket->so_rcv));
+ sctp_clog.x.lock.socksndbuf_lock = mtx_owned(SOCKBUF_MTX(&inp->sctp_socket->so_snd));
} else {
sctp_clog.x.lock.sock_lock = SCTP_LOCK_UNKNOWN;
sctp_clog.x.lock.sockrcvbuf_lock = SCTP_LOCK_UNKNOWN;
diff --git a/sys/sys/socketvar.h b/sys/sys/socketvar.h
index 295a1cf3d37f..dbd9804a980d 100644
--- a/sys/sys/socketvar.h
+++ b/sys/sys/socketvar.h
@@ -218,7 +218,7 @@ struct socket {
#ifdef _KERNEL
-#define SOCK_MTX(so) &(so)->so_lock
+#define SOCK_MTX(so) (&(so)->so_lock)
#define SOCK_LOCK(so) mtx_lock(&(so)->so_lock)
#define SOCK_OWNED(so) mtx_owned(&(so)->so_lock)
#define SOCK_UNLOCK(so) mtx_unlock(&(so)->so_lock)
More information about the dev-commits-src-main
mailing list