aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Tuexen <tuexen@fh-muenster.de>2020-03-24 13:26:03 +0100
committerMichael Tuexen <tuexen@fh-muenster.de>2020-03-24 13:26:03 +0100
commit9c25344990880917f27a4dd4b0dcc912de5f6ef9 (patch)
tree65b3e55e10eb5c604cfaf6616e04e684aee57371
parent134be30cfc14e50aff16d42899a5adfef110ed10 (diff)
downloadusrsctp-9c25344990880917f27a4dd4b0dcc912de5f6ef9.tar.gz
Add some lock asserts, which will be used shortly.
-rwxr-xr-xusrsctplib/netinet/sctp_lock_userspace.h8
-rwxr-xr-xusrsctplib/netinet/sctp_process_lock.h14
2 files changed, 15 insertions, 7 deletions
diff --git a/usrsctplib/netinet/sctp_lock_userspace.h b/usrsctplib/netinet/sctp_lock_userspace.h
index 7b8b0cbd..fe496bf5 100755
--- a/usrsctplib/netinet/sctp_lock_userspace.h
+++ b/usrsctplib/netinet/sctp_lock_userspace.h
@@ -68,7 +68,7 @@ __FBSDID("$FreeBSD$");
#define SCTP_WQ_ADDR_DESTROY()
#define SCTP_WQ_ADDR_LOCK()
#define SCTP_WQ_ADDR_UNLOCK()
-
+#define SCTP_WQ_ADDR_LOCK_ASSERT()
#define SCTP_IPI_ADDR_INIT()
#define SCTP_IPI_ADDR_DESTROY()
@@ -82,14 +82,11 @@ __FBSDID("$FreeBSD$");
#define SCTP_IPI_ITERATOR_WQ_LOCK()
#define SCTP_IPI_ITERATOR_WQ_UNLOCK()
-
#define SCTP_IP_PKTLOG_INIT()
#define SCTP_IP_PKTLOG_LOCK()
#define SCTP_IP_PKTLOG_UNLOCK()
#define SCTP_IP_PKTLOG_DESTROY()
-
-
#define SCTP_INP_READ_INIT(_inp)
#define SCTP_INP_READ_DESTROY(_inp)
#define SCTP_INP_READ_LOCK(_inp)
@@ -100,9 +97,10 @@ __FBSDID("$FreeBSD$");
#define SCTP_INP_LOCK_DESTROY(_inp)
#define SCTP_ASOC_CREATE_LOCK_DESTROY(_inp)
-
#define SCTP_INP_RLOCK(_inp)
#define SCTP_INP_WLOCK(_inp)
+#define SCTP_INP_RLOCK_ASSERT(_inp)
+#define SCTP_INP_WLOCK_ASSERT(_inp)
#define SCTP_INP_LOCK_CONTENDED(_inp) (0) /* Don't know if this is possible */
diff --git a/usrsctplib/netinet/sctp_process_lock.h b/usrsctplib/netinet/sctp_process_lock.h
index ca669212..17cfd077 100755
--- a/usrsctplib/netinet/sctp_process_lock.h
+++ b/usrsctplib/netinet/sctp_process_lock.h
@@ -86,7 +86,9 @@
#define SCTP_INP_RLOCK(_inp)
#define SCTP_INP_RUNLOCK(_inp)
#define SCTP_INP_WLOCK(_inp)
-#define SCTP_INP_WUNLOCK(_inep)
+#define SCTP_INP_WUNLOCK(_inp)
+#define SCTP_INP_RLOCK_ASSERT(_inp)
+#define SCTP_INP_WLOCK_ASSERT(_inp)
#define SCTP_INP_INCR_REF(_inp)
#define SCTP_INP_DECR_REF(_inp)
@@ -124,7 +126,7 @@
EnterCriticalSection(&SCTP_BASE_INFO(wq_addr_mtx))
#define SCTP_WQ_ADDR_UNLOCK() \
LeaveCriticalSection(&SCTP_BASE_INFO(wq_addr_mtx))
-
+#define SCTP_WQ_ADDR_ASSERT()
#define SCTP_INP_INFO_LOCK_INIT() \
InitializeCriticalSection(&SCTP_BASE_INFO(ipi_ep_mtx))
@@ -185,6 +187,8 @@
#define SCTP_INP_WLOCK(_inp) \
EnterCriticalSection(&(_inp)->inp_mtx)
#endif
+#define SCTP_INP_RLOCK_ASSERT(_tcb)
+#define SCTP_INP_WLOCK_ASSERT(_tcb)
#define SCTP_TCB_SEND_LOCK_INIT(_tcb) \
InitializeCriticalSection(&(_tcb)->tcb_send_mtx)
@@ -263,6 +267,8 @@
#define SCTP_WQ_ADDR_UNLOCK() \
(void)pthread_mutex_unlock(&SCTP_BASE_INFO(wq_addr_mtx))
#endif
+#define SCTP_WQ_ADDR_LOCK_ASSERT() \
+ KASSERT(pthread_mutex_trylock(&SCTP_BASE_INFO(wq_addr_mtx)) == EBUSY, ("%s: wq_addr_mtx not locked", __func__))
#define SCTP_INP_INFO_LOCK_INIT() \
(void)pthread_mutex_init(&SCTP_BASE_INFO(ipi_ep_mtx), &SCTP_BASE_VAR(mtx_attr))
@@ -377,6 +383,10 @@
#define SCTP_INP_WUNLOCK(_inp) \
(void)pthread_mutex_unlock(&(_inp)->inp_mtx)
#endif
+#define SCTP_INP_RLOCK_ASSERT(_inp) \
+ KASSERT(pthread_mutex_trylock(&(_inp)->inp_mtx) == EBUSY, ("%s: inp_mtx not locked", __func__))
+#define SCTP_INP_WLOCK_ASSERT(_inp) \
+ KASSERT(pthread_mutex_trylock(&(_inp)->inp_mtx) == EBUSY, ("%s: inp_mtx not locked", __func__))
#define SCTP_INP_INCR_REF(_inp) atomic_add_int(&((_inp)->refcount), 1)
#define SCTP_INP_DECR_REF(_inp) atomic_add_int(&((_inp)->refcount), -1)