summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaymondWu <xywu@marvell.com>2010-12-01 16:54:28 +0800
committerLi Li <lea.li@marvell.com>2010-12-09 14:10:47 +0800
commit2480ad44abc91336d633613ad0b7aea167af366f (patch)
tree4b922d3e2784868534ba8c3b41cd311fd39218bb
parentb52a3070bb7ba7849161237d82ee9916abba51b6 (diff)
Fix pthread memory leakage issue.
Since we use child thread to monitor parent thread. The child thread will not release resources created by parent. So we detach it manually. Change-Id: Ia7cf2f595cfd2215bdfafca6ca3da2677978d815 Signed-off-by: RaymondWu <xywu@marvell.com>
-rwxr-xr-xvmeta_lib.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/vmeta_lib.c b/vmeta_lib.c
index b7a8c5f..a72951c 100755
--- a/vmeta_lib.c
+++ b/vmeta_lib.c
@@ -832,6 +832,8 @@ int vmeta_thread_monitor(struct monitor_data * pmd)
if(p_cb->kernel_share_va==0 || pmd == NULL)
{
dbg_printf(VDEC_DEBUG_ALL,"vdec_os_api_free_user_id error: not init yet\n");
+ free(pmd);
+ pthread_detach(pthread_self());
pthread_mutex_unlock(&pmt);
return -1;
}
@@ -839,6 +841,8 @@ int vmeta_thread_monitor(struct monitor_data * pmd)
p_md = malloc(sizeof(struct monitor_data));
if(p_md == NULL)
{
+ free(pmd);
+ pthread_detach(pthread_self());
pthread_mutex_unlock(&pmt);
return -1;
}
@@ -900,6 +904,7 @@ int vmeta_thread_monitor(struct monitor_data * pmd)
pthread_attr_destroy(&pat);
dbg_printf(VDEC_DEBUG_MEM,"thread monitor exit\n");
+ pthread_detach(pthread_self());
pthread_mutex_unlock(&pmt);
return 0;
@@ -907,6 +912,7 @@ tag_monitor_fail:
pthread_mutex_unlock(&pmt);
free(p_md);
free(pmd);
+ pthread_detach(pthread_self());
pthread_attr_destroy(&pat);
return -1;