Skip to content

Commit

Permalink
[bg] fix memory leak in vfs-async-task introduced in 6d40124 #582
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnorantGuru committed Sep 28, 2015
1 parent 78322be commit d23b731
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/vfs/vfs-async-task.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ void vfs_async_task_finalize(GObject *object)
}
*/

// since we don't use g_thread_join, free the GThread
if ( task->thread )
{
g_thread_unref( task->thread );
task->thread = NULL;
}

// wait for unlock vfs_async_task_thread - race condition ?
// This lock+unlock is probably no longer needed - race fixed
g_mutex_lock( task->lock );
Expand Down Expand Up @@ -175,7 +182,6 @@ gpointer vfs_async_task_thread( gpointer _task )
// due to rare race condition ?
g_object_ref( task );
task->finished = TRUE;
task->thread = NULL;
task->ret_val = ret;
task->cancelled = task->cancel;
if ( task->cancel_cond )
Expand Down Expand Up @@ -210,7 +216,7 @@ void vfs_async_task_execute( VFSAsyncTask* task )
void vfs_async_task_cancel( VFSAsyncTask* task )
{
//printf("vfs_async_task_cancel task=%p thread=%p self=%p\n", task, task->thread, g_thread_self() );
if( ! task->thread )
if( task->finished )
return;
/* This function sets cancel and waits for the async thread to exit.
*
Expand Down

0 comments on commit d23b731

Please sign in to comment.