Skip to content
Snippets Groups Projects
Commit 1b9a3b5b authored by Nadav Har'El's avatar Nadav Har'El
Browse files

BSD porting: implement mtx_assert()

Trivially implement mtx_assert(). This would catch the "ifconfig" bug
fixed in the previous patch - where ifconfig called sofree() without
the accept lock.
parent 073d9ea7
No related branches found
No related tags found
No related merge requests found
#include <osv/mutex.h>
#include <stdlib.h>
#include <bsd/porting/sync_stub.h>
......@@ -24,5 +25,18 @@ void mtx_unlock(struct mtx *mp)
void mtx_assert(struct mtx *mp, int flag)
{
switch (flag) {
case MA_OWNED:
if (!mutex_owned(&mp->_mutex)) {
abort();
}
break;
case MA_NOTOWNED:
if (mutex_owned(&mp->_mutex)) {
abort();
}
break;
default:
abort();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment