Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 465f11d5 authored by Shuzhen Wang's avatar Shuzhen Wang
Browse files

ExternalCamera: Fix a deadlock crash using std::thread

It's not a good idea to call join() from std::thread's destructor.

In this case, the order of sequence is:

1. OutputThread::threadLoop runs to completion, holding the last
   ExternalCameraDeviceSession reference,
2. Upon exiting OutputThread::threadLopp, ~ExternalCameraDeviceSession
   is called, which calls OutputThread.requestExitAndWait()

In this sequence, the requesetExitAndWait() is joining on itself,
causing deadlock. Check the calling thread id before calling
'join'. If the calling thread id matches the 'thread' object's thread
id, use 'detach' instead.

Test: Run VTS on a USB camera
Flag: EXEMPT bugfix
Bug: 399939768
Change-Id: Ic39a2d54828f4269a29ba047dee8e6644fef62a4
parent 2aacbf05
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment