binder: prevent long delays in zombie reaping

The check for zombies was being done before binder_put_thread
which meant that any object that became a zombie could not
be handled right away even if safe. Also, need to trigger
zombie handling when deferring put_files_struct().

This manifested as long delays in adb completing a command
because the files_struct stayed alive longer than it should
have.

Bug: 36358874
Change-Id: Ib8f8b6cd3ea583342b9f39f1bab71a7948ec4bac
Test: tested and confirmed by bug submitter
Signed-off-by: Todd Kjos <tkjos@google.com>
This commit is contained in:
Todd Kjos
2017-03-20 12:12:16 -07:00
parent 4e534d7d01
commit a790f8b2ad

View File

@@ -3714,8 +3714,8 @@ err:
binder_proc_lock(thread->proc, __LINE__);
WRITE_ONCE(thread->looper_need_return, false);
binder_proc_unlock(thread->proc, __LINE__);
zombie_cleanup_check(proc);
binder_put_thread(thread);
zombie_cleanup_check(proc);
}
wait_event_interruptible(binder_user_error_wait, binder_stop_on_user_error < 2);
if (ret && ret != -ERESTARTSYS)
@@ -4244,6 +4244,7 @@ static void binder_deferred_func(struct work_struct *work)
proc->zombie_files = proc->files;
proc->files = NULL;
binder_queue_for_zombie_cleanup(proc);
defer |= BINDER_ZOMBIE_CLEANUP;
}
binder_proc_unlock(proc, __LINE__);
}