C client: Fix crash on process exit on linux

This commit is contained in:
UnknownShadow200 2018-09-11 09:24:53 +10:00
parent cd1961f588
commit a88d912859

View File

@ -235,20 +235,21 @@ static void AsyncDownloader_CompleteResult(struct AsyncRequest* request) {
}
static void AsyncDownloader_WorkerFunc(void) {
while (true) {
for (;;) {
struct AsyncRequest request;
bool hasRequest = false;
bool hasRequest = false, stop;
Mutex_Lock(async_pendingMutex);
{
if (async_terminate) return;
if (async_pending.Count) {
stop = async_terminate;
if (!stop && async_pending.Count) {
request = async_pending.Requests[0];
hasRequest = true;
AsyncRequestList_RemoveAt(&async_pending, 0);
}
}
Mutex_Unlock(async_pendingMutex);
if (stop) return;
if (hasRequest) {
Platform_LogConst("Got something to do!");
@ -283,8 +284,8 @@ static void AsyncDownloader_Init(void) {
Http_Init();
async_waitable = Waitable_Create();
async_pendingMutex = Mutex_Create();
async_processedMutex = Mutex_Create();
async_pendingMutex = Mutex_Create();
async_processedMutex = Mutex_Create();
async_curRequestMutex = Mutex_Create();
async_workerThread = Thread_Start(AsyncDownloader_WorkerFunc, false);
}