Skip to content
Snippets Groups Projects
Commit b2657c5d authored by Utz-Uwe Haus's avatar Utz-Uwe Haus
Browse files

add mstro_memlock_finalize function

parent 9b26d7af
Branches
No related tags found
2 merge requests!3Jsc ci update,!2update JSC-CI branch to devel
...@@ -83,6 +83,12 @@ mstro_memunlock(void* addr, size_t len); ...@@ -83,6 +83,12 @@ mstro_memunlock(void* addr, size_t len);
mstro_status mstro_status
mstro_memlock_init(size_t min_required); mstro_memlock_init(size_t min_required);
/**@brief De-Initialize the memlock subsystem
*
*/
mstro_status
mstro_memlock_finalize(void);
/**@} (end of group MSTRO_I_MEMLOCK) */ /**@} (end of group MSTRO_I_MEMLOCK) */
/**@} (end of group MSTRO_Internal) */ /**@} (end of group MSTRO_Internal) */
......
...@@ -371,7 +371,7 @@ mstro_core_finalize(void) ...@@ -371,7 +371,7 @@ mstro_core_finalize(void)
goto BAILOUT; goto BAILOUT;
} }
status = MSTRO_OK; status = mstro_memlock_finalize();
BAILOUT: BAILOUT:
return status; return status;
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#include <pthread.h> #include <pthread.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <errno.h> #include <errno.h>
#include <sys/time.h>
#include <sys/resource.h>
/* Terminology: /* Terminology:
* *
...@@ -119,6 +121,28 @@ mstro_memlock_init(size_t min_required) ...@@ -119,6 +121,28 @@ mstro_memlock_init(size_t min_required)
} }
mstro_status
mstro_memlock_finalize(void)
{
mstro_status s=MSTRO_OK;
WITH_LOCKED_PAGETABLE({
if(g_locked_pages) {
if(kh_size(g_locked_pages)!=0) {
ERR("Table of locked page-sets nonempty: %d live entries\n",
kh_size(g_locked_pages));
s=MSTRO_FAIL;
}
kh_destroy(page_set, g_locked_pages);
} else {
ERR("called before init, or called twice\n");
}
}, BAILOUT);
BAILOUT:
return s;
}
/** check whether @arg page is locked. /** check whether @arg page is locked.
* *
* Must be called while holding @ref g_locked_pages_mtx. * Must be called while holding @ref g_locked_pages_mtx.
......
...@@ -56,6 +56,7 @@ CHEAT_TEST(lock_unlock, ...@@ -56,6 +56,7 @@ CHEAT_TEST(lock_unlock,
cheat_assert(MSTRO_OK==mstro_memunlock(x,8000)); cheat_assert(MSTRO_OK==mstro_memunlock(x,8000));
free(x); free(x);
cheat_assert(MSTRO_OK==mstro_memlock_finalize());
}) })
...@@ -78,6 +79,7 @@ CHEAT_TEST(lock_unlock_multi, ...@@ -78,6 +79,7 @@ CHEAT_TEST(lock_unlock_multi,
cheat_assert(MSTRO_FAIL==mstro_memunlock(x,8000)); cheat_assert(MSTRO_FAIL==mstro_memunlock(x,8000));
free(x); free(x);
cheat_assert(MSTRO_OK==mstro_memlock_finalize());
}) })
CHEAT_TEST(lock_overlapping, CHEAT_TEST(lock_overlapping,
...@@ -108,6 +110,5 @@ CHEAT_TEST(lock_overlapping, ...@@ -108,6 +110,5 @@ CHEAT_TEST(lock_overlapping,
cheat_assert(MSTRO_OK==mstro_memunlock(start3, len3)); cheat_assert(MSTRO_OK==mstro_memunlock(start3, len3));
free(x); free(x);
cheat_assert(MSTRO_OK==mstro_memlock_finalize());
}) })
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment