Piotr Caban piotr@codeweavers.com writes:
- read = 0;
- size = buffers->dwBufferLength;
- EnterCriticalSection( &req->read_section );
- while(1) {
res = HTTPREQ_Read(req, (char*)buffers->lpvBuffer+read, size-read,
&buffers->dwBufferLength, !(flags & IRF_NO_WAIT));
if(res == ERROR_SUCCESS)
read += buffers->dwBufferLength;
else
break;
if(!req->read_chunked || read==size || req->dwContentLength!=req->dwContentRead
|| !req->dwContentLength || (req->gzip_stream && req->gzip_stream->end_of_data))
break;
INTERNET_SendCallback(&req->hdr, req->hdr.dwContext, INTERNET_STATUS_RESPONSE_RECEIVED,
&buffers->dwBufferLength, sizeof(buffers->dwBufferLength));
INTERNET_SendCallback(&req->hdr, req->hdr.dwContext,
INTERNET_STATUS_RECEIVING_RESPONSE, NULL, 0);
Calling the callbacks while holding the critical section is not a good idea.