mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-16 15:11:52 +00:00
Fix _sx_assert() to panic() rather than printf() when an assertion fails
and ignore assertions if we have already paniced.
This commit is contained in:
parent
0e2ff2832c
commit
03129ba97f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=126316
@ -322,6 +322,8 @@ void
|
||||
_sx_assert(struct sx *sx, int what, const char *file, int line)
|
||||
{
|
||||
|
||||
if (panicstr != NULL)
|
||||
return;
|
||||
switch (what) {
|
||||
case SX_LOCKED:
|
||||
case SX_SLOCKED:
|
||||
@ -331,7 +333,7 @@ _sx_assert(struct sx *sx, int what, const char *file, int line)
|
||||
mtx_lock(sx->sx_lock);
|
||||
if (sx->sx_cnt <= 0 &&
|
||||
(what == SX_SLOCKED || sx->sx_xholder != curthread))
|
||||
printf("Lock %s not %slocked @ %s:%d\n",
|
||||
panic("Lock %s not %slocked @ %s:%d\n",
|
||||
sx->sx_object.lo_name, (what == SX_SLOCKED) ?
|
||||
"share " : "", file, line);
|
||||
mtx_unlock(sx->sx_lock);
|
||||
@ -340,7 +342,7 @@ _sx_assert(struct sx *sx, int what, const char *file, int line)
|
||||
case SX_XLOCKED:
|
||||
mtx_lock(sx->sx_lock);
|
||||
if (sx->sx_xholder != curthread)
|
||||
printf("Lock %s not exclusively locked @ %s:%d\n",
|
||||
panic("Lock %s not exclusively locked @ %s:%d\n",
|
||||
sx->sx_object.lo_name, file, line);
|
||||
mtx_unlock(sx->sx_lock);
|
||||
break;
|
||||
@ -354,7 +356,7 @@ _sx_assert(struct sx *sx, int what, const char *file, int line)
|
||||
*/
|
||||
mtx_lock(sx->sx_lock);
|
||||
if (sx->sx_xholder == curthread)
|
||||
printf("Lock %s locked @ %s:%d\n",
|
||||
panic("Lock %s exclusively locked @ %s:%d\n",
|
||||
sx->sx_object.lo_name, file, line);
|
||||
mtx_unlock(sx->sx_lock);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user