diff mbox

[API-NEXT,PATCHv5,11/13] linux-gen: _ishm: cleaning remaining block at odp_term_global

Message ID 1477667786-19330-12-git-send-email-christophe.milard@linaro.org
State Superseded
Headers show

Commit Message

Christophe Milard Oct. 28, 2016, 3:16 p.m. UTC
Remaining (forgotten, not freed) blocks are gathered and related files
cleaned when odp_term_global() is called. An error message is also issued
so the application writters get to know about these blocks

Signed-off-by: Christophe Milard <christophe.milard@linaro.org>

---
 platform/linux-generic/_ishm.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

-- 
2.7.4
diff mbox

Patch

diff --git a/platform/linux-generic/_ishm.c b/platform/linux-generic/_ishm.c
index 17b186f..0586a96 100644
--- a/platform/linux-generic/_ishm.c
+++ b/platform/linux-generic/_ishm.c
@@ -1505,12 +1505,25 @@  int _odp_ishm_term_local(void)
 int _odp_ishm_term_global(void)
 {
 	int ret = 0;
+	int index;
+	ishm_block_t *block;
 
 	if ((getpid() != odp_global_data.main_pid) ||
 	    (syscall(SYS_gettid) != getpid()))
 		ODP_ERR("odp_term_global() must be performed by the main "
 			"ODP process!\n.");
 
+	/* cleanup possibly non freed memory (and complain a bit): */
+	for (index = 0; index < ISHM_MAX_NB_BLOCKS; index++) {
+		block = &ishm_tbl->block[index];
+		if (block->len != 0) {
+			ODP_ERR("block '%s' (file %s) was never freed "
+				"(cleaning up...).\n",
+				block->name, block->filename);
+			delete_file(block);
+		}
+	}
+
 	/* perform the last thread terminate which was postponed: */
 	ret = do_odp_ishm_term_local();