aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/sockbuf.h
diff options
context:
space:
mode:
authorKip Macy <kmacy@FreeBSD.org>2008-07-31 20:27:50 +0000
committerKip Macy <kmacy@FreeBSD.org>2008-07-31 20:27:50 +0000
commit849cca9b8e2440cf331fb077113e5d0be0551d31 (patch)
tree48b0986878a5863a3ae8e4f44ab263822307c161 /sys/sys/sockbuf.h
parent8d4e4b790adba9b068e9bd9eff42395bf5c0dac2 (diff)
downloadsrc-849cca9b8e2440cf331fb077113e5d0be0551d31.tar.gz
src-849cca9b8e2440cf331fb077113e5d0be0551d31.zip
move sockbuf locking macros in to sockbuf.h
Notes
Notes: svn path=/head/; revision=181066
Diffstat (limited to 'sys/sys/sockbuf.h')
-rw-r--r--sys/sys/sockbuf.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/sys/sys/sockbuf.h b/sys/sys/sockbuf.h
index f736c4dd3de2..b081114a4327 100644
--- a/sys/sys/sockbuf.h
+++ b/sys/sys/sockbuf.h
@@ -32,6 +32,10 @@
*/
#ifndef _SYS_SOCKBUF_H_
#define _SYS_SOCKBUF_H_
+#include <sys/selinfo.h> /* for struct selinfo */
+#include <sys/_lock.h>
+#include <sys/_mutex.h>
+#include <sys/_sx.h>
#define SB_MAX (256*1024) /* default for max chars in sockbuf */
@@ -99,6 +103,20 @@ struct sockbuf {
#ifdef _KERNEL
+/*
+ * Per-socket buffer mutex used to protect most fields in the socket
+ * buffer.
+ */
+#define SOCKBUF_MTX(_sb) (&(_sb)->sb_mtx)
+#define SOCKBUF_LOCK_INIT(_sb, _name) \
+ mtx_init(SOCKBUF_MTX(_sb), _name, NULL, MTX_DEF)
+#define SOCKBUF_LOCK_DESTROY(_sb) mtx_destroy(SOCKBUF_MTX(_sb))
+#define SOCKBUF_LOCK(_sb) mtx_lock(SOCKBUF_MTX(_sb))
+#define SOCKBUF_OWNED(_sb) mtx_owned(SOCKBUF_MTX(_sb))
+#define SOCKBUF_UNLOCK(_sb) mtx_unlock(SOCKBUF_MTX(_sb))
+#define SOCKBUF_LOCK_ASSERT(_sb) mtx_assert(SOCKBUF_MTX(_sb), MA_OWNED)
+#define SOCKBUF_UNLOCK_ASSERT(_sb) mtx_assert(SOCKBUF_MTX(_sb), MA_NOTOWNED)
+
void sbappend(struct sockbuf *sb, struct mbuf *m);
void sbappend_locked(struct sockbuf *sb, struct mbuf *m);
void sbappendstream(struct sockbuf *sb, struct mbuf *m);