Print this page
usr/src/lib/libfakekernel/common/mutex.c
@@ -8,11 +8,11 @@
* source. A copy of the CDDL is also available via the Internet at
* http://www.illumos.org/license/CDDL.
*/
/*
- * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2018 Nexenta Systems, Inc. All rights reserved.
* Copyright 2017 RackTop Systems.
*/
/*
* mutex(9f)
@@ -29,12 +29,13 @@
int _lwp_mutex_unlock(lwp_mutex_t *);
int _lwp_mutex_trylock(lwp_mutex_t *);
extern clock_t ddi_get_lbolt(void);
+/* See: head/synch.h ERRORCHECKMUTEX */
static const lwp_mutex_t default_mutex =
- {{0, 0, 0, {USYNC_THREAD}, _MUTEX_MAGIC},
+ {{0, 0, 0, {USYNC_THREAD|LOCK_ERRORCHECK}, _MUTEX_MAGIC},
{{{0, 0, 0, 0, 0, 0, 0, 0}}}, 0};
/* ARGSUSED */
void
kmutex_init(kmutex_t *mp, char *name, kmutex_type_t typ, void *arg)
@@ -51,12 +52,15 @@
}
void
kmutex_enter(kmutex_t *mp)
{
+ kthread_t *t = _curthread();
+
+ VERIFY(mp->m_owner != t);
VERIFY(0 == _lwp_mutex_lock(&mp->m_lock));
- mp->m_owner = _curthread();
+ mp->m_owner = t;
}
int
mutex_tryenter(kmutex_t *mp)
{