History

fix potential deadlock prob in multi-thread

sijchen@cisco.com committed 9 years ago

Commit c51a4ff1 parent 4484df46 files · +65 −26Browse files

Showing the changes to codec/common/src/WelsThread.cpp (1 of 6 files). Show all

Unified · Split

codec/common/src/WelsThread.cpp+5−4
@@ -49,7 +49,7 @@ CWelsThread::CWelsThread() : · 48 unmodified lines
4949
5050 WelsEventOpen (&m_hEvent);
5151 WelsMutexInit(&m_hMutex);
52−
52+ m_iConVar = 1;
5353 }
5454
5555 CWelsThread::~CWelsThread() {
@@ -60,13 +60,14 @@ CWelsThread::~CWelsThread() { · 4 unmodified lines
6060
6161 void CWelsThread::Thread() {
6262 while (true) {
63− WelsEventWait (&m_hEvent,&m_hMutex);
63+ WelsEventWait (&m_hEvent,&m_hMutex,m_iConVar);
6464
6565 if (GetEndFlag()) {
6666 break;
6767 }
6868
69− ExecuteTask();
69+ m_iConVar = 1;
70+ ExecuteTask();//in ExecuteTask there will be OnTaskStop which opens the potential new Signaling of next run, so the setting of m_iConVar = 1 should be before ExecuteTask()
7071 }
7172
7273 SetRunning (false);
@@ -105,7 +106,7 @@ void CWelsThread::Kill() { · 32 unmodified lines
105106
106107 SetEndFlag (true);
107108
108− WelsEventSignal (&m_hEvent);
109+ WelsEventSignal (&m_hEvent,&m_hMutex,&m_iConVar);
109110 WelsThreadJoin (m_hThread);
110111 return;
111112 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t