Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F153190804
D31900.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D31900.diff
View Options
diff --git a/sys/sys/sockbuf.h b/sys/sys/sockbuf.h
--- a/sys/sys/sockbuf.h
+++ b/sys/sys/sockbuf.h
@@ -118,8 +118,11 @@
#ifdef _KERNEL
/*
- * Per-socket buffer mutex used to protect most fields in the socket
- * buffer.
+ * Per-socket buffer mutex used to protect most fields in the socket buffer.
+ * These make use of the mutex pointer embedded in struct sockbuf, which
+ * currently just references mutexes in the containing socket. The
+ * SOCK_SENDBUF_LOCK() etc. macros can be used instead of or in combination with
+ * these locking macros.
*/
#define SOCKBUF_MTX(_sb) ((_sb)->sb_mtx)
#define SOCKBUF_LOCK_INIT(_sb, _name) \
diff --git a/sys/sys/socketvar.h b/sys/sys/socketvar.h
--- a/sys/sys/socketvar.h
+++ b/sys/sys/socketvar.h
@@ -77,8 +77,8 @@
* Locking key to struct socket:
* (a) constant after allocation, no locking required.
* (b) locked by SOCK_LOCK(so).
- * (cr) locked by SOCKBUF_LOCK(&so->so_rcv).
- * (cs) locked by SOCKBUF_LOCK(&so->so_snd).
+ * (cr) locked by SOCK_RECVBUF_LOCK(so)/SOCKBUF_LOCK(&so->so_rcv).
+ * (cs) locked by SOCK_SENDBUF_LOCK(so)/SOCKBUF_LOCK(&so->so_snd).
* (e) locked by SOLISTEN_LOCK() of corresponding listening socket.
* (f) not locked since integer reads/writes are atomic.
* (g) used only as a sleep/wakeup address, no value.
@@ -255,6 +255,32 @@
("%s: %p not listening", __func__, (sol))); \
} while (0)
+/*
+ * Socket buffer locks. These manipulate the same mutexes as SOCKBUF_LOCK()
+ * and related macros.
+ */
+#define SOCK_RECVBUF_MTX(so) \
+ (&(so)->so_rcv_mtx)
+#define SOCK_RECVBUF_LOCK(so) \
+ mtx_lock(SOCK_RECVBUF_MTX(so))
+#define SOCK_RECVBUF_UNLOCK(so) \
+ mtx_unlock(SOCK_RECVBUF_MTX(so))
+#define SOCK_RECVBUF_LOCK_ASSERT(so) \
+ mtx_assert(SOCK_RECVBUF_MTX(so), MA_OWNED)
+#define SOCK_RECVBUF_UNLOCK_ASSERT(so) \
+ mtx_assert(SOCK_RECVBUF_MTX(so), MA_NOTOWNED)
+
+#define SOCK_SENDBUF_MTX(so) \
+ (&(so)->so_snd_mtx)
+#define SOCK_SENDBUF_LOCK(so) \
+ mtx_lock(SOCK_SENDBUF_MTX(so))
+#define SOCK_SENDBUF_UNLOCK(so) \
+ mtx_unlock(SOCK_SENDBUF_MTX(so))
+#define SOCK_SENDBUF_LOCK_ASSERT(so) \
+ mtx_assert(SOCK_SENDBUF_MTX(so), MA_OWNED)
+#define SOCK_SENDBUF_UNLOCK_ASSERT(so) \
+ mtx_assert(SOCK_SENDBUF_MTX(so), MA_NOTOWNED)
+
/*
* Macros for sockets and socket buffering.
*/
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Apr 20, 5:15 PM (4 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31853088
Default Alt Text
D31900.diff (2 KB)
Attached To
Mode
D31900: socket: Add macros to lock socket buffers using socket references
Attached
Detach File
Event Timeline
Log In to Comment