Add a counter to keep track of the number of outstanding async
requests. This gets around a problem where a SetEvent could be called before a previous event had been dealt with.
This commit is contained in:
parent
8d74ef1030
commit
a3f03e1cd2
|
@ -89,6 +89,7 @@ VOID INTERNET_ExecuteWork();
|
||||||
DWORD g_dwTlsErrIndex = TLS_OUT_OF_INDEXES;
|
DWORD g_dwTlsErrIndex = TLS_OUT_OF_INDEXES;
|
||||||
DWORD dwNumThreads;
|
DWORD dwNumThreads;
|
||||||
DWORD dwNumIdleThreads;
|
DWORD dwNumIdleThreads;
|
||||||
|
DWORD dwNumJobs;
|
||||||
HANDLE hEventArray[2];
|
HANDLE hEventArray[2];
|
||||||
#define hQuitEvent hEventArray[0]
|
#define hQuitEvent hEventArray[0]
|
||||||
#define hWorkEvent hEventArray[1]
|
#define hWorkEvent hEventArray[1]
|
||||||
|
@ -127,6 +128,7 @@ BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||||
|
|
||||||
dwNumThreads = 0;
|
dwNumThreads = 0;
|
||||||
dwNumIdleThreads = 0;
|
dwNumIdleThreads = 0;
|
||||||
|
dwNumJobs = 0;
|
||||||
|
|
||||||
case DLL_THREAD_ATTACH:
|
case DLL_THREAD_ATTACH:
|
||||||
{
|
{
|
||||||
|
@ -1674,6 +1676,10 @@ DWORD INTERNET_WorkerThreadFunc(LPVOID *lpvParam)
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
if(dwNumJobs > 0) {
|
||||||
|
INTERNET_ExecuteWork();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
dwWaitRes = WaitForMultipleObjects(2, hEventArray, FALSE, MAX_IDLE_WORKER);
|
dwWaitRes = WaitForMultipleObjects(2, hEventArray, FALSE, MAX_IDLE_WORKER);
|
||||||
|
|
||||||
if (dwWaitRes == WAIT_OBJECT_0 + 1)
|
if (dwWaitRes == WAIT_OBJECT_0 + 1)
|
||||||
|
@ -1724,6 +1730,7 @@ BOOL INTERNET_InsertWorkRequest(LPWORKREQUEST lpWorkRequest)
|
||||||
LeaveCriticalSection(&csQueue);
|
LeaveCriticalSection(&csQueue);
|
||||||
|
|
||||||
bSuccess = TRUE;
|
bSuccess = TRUE;
|
||||||
|
InterlockedIncrement(&dwNumJobs);
|
||||||
}
|
}
|
||||||
|
|
||||||
return bSuccess;
|
return bSuccess;
|
||||||
|
@ -1762,6 +1769,7 @@ BOOL INTERNET_GetWorkRequest(LPWORKREQUEST lpWorkRequest)
|
||||||
memcpy(lpWorkRequest, lpRequest, sizeof(WORKREQUEST));
|
memcpy(lpWorkRequest, lpRequest, sizeof(WORKREQUEST));
|
||||||
HeapFree(GetProcessHeap(), 0, lpRequest);
|
HeapFree(GetProcessHeap(), 0, lpRequest);
|
||||||
bSuccess = TRUE;
|
bSuccess = TRUE;
|
||||||
|
InterlockedDecrement(&dwNumJobs);
|
||||||
}
|
}
|
||||||
|
|
||||||
return bSuccess;
|
return bSuccess;
|
||||||
|
@ -1824,6 +1832,7 @@ VOID INTERNET_ExecuteWork()
|
||||||
|
|
||||||
if (INTERNET_GetWorkRequest(&workRequest))
|
if (INTERNET_GetWorkRequest(&workRequest))
|
||||||
{
|
{
|
||||||
|
TRACE("Got work %d\n", workRequest.asyncall);
|
||||||
switch (workRequest.asyncall)
|
switch (workRequest.asyncall)
|
||||||
{
|
{
|
||||||
case FTPPUTFILEA:
|
case FTPPUTFILEA:
|
||||||
|
|
Loading…
Reference in New Issue