wininet: Don't start the next chunk if the read is satisfied.

Jacek Caban jacek at codeweavers.com
Wed Sep 4 06:11:22 CDT 2013


Hi Hans,

On 09/04/13 09:22, Hans Leidekker wrote:
> ---
>  dlls/wininet/http.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
> index 1832b4f..521e4aa 100644
> --- a/dlls/wininet/http.c
> +++ b/dlls/wininet/http.c
> @@ -2795,7 +2795,7 @@ static DWORD chunked_read(data_stream_t *stream, http_request_t *req, BYTE *buf,
>      chunked_stream_t *chunked_stream = (chunked_stream_t*)stream;
>      DWORD read_bytes = 0, ret_read = 0, res = ERROR_SUCCESS;
>  
> -    if(chunked_stream->chunk_size == ~0u) {
> +    if(!chunked_stream->chunk_size || chunked_stream->chunk_size == ~0u) {
>          res = start_next_chunk(chunked_stream, req);
>          if(res != ERROR_SUCCESS)
>              return res;
> @@ -2835,7 +2835,7 @@ static DWORD chunked_read(data_stream_t *stream, http_request_t *req, BYTE *buf,
>          chunked_stream->chunk_size -= read_bytes;
>          size -= read_bytes;
>          ret_read += read_bytes;
> -        if(!chunked_stream->chunk_size) {
> +        if(size && !chunked_stream->chunk_size) {
>              assert(read_mode != READMODE_NOBLOCK);
>              res = start_next_chunk(chunked_stream, req);
>              if(res != ERROR_SUCCESS)

This patch breaks two assumptions:
- chunk_size outside chunked_read means the end of the stream
- READMODE_SYNC should read as much data as possible

There is longer story about the way it's implemented the way it is.
Native IE in the past considered zero-length reporting data in
INTERNET_STATUS_REQUEST_COMPLETE to be an error. If you stop reading in
the end of chunk and the next chunk is the last one, then you will send
such report asynchronously. That's why we read the whole chunk only if
we can start reading the next one (and we can't if we don't want to
block). Now I think that the failure could possibly be caused by a
combination of returning zero size and some other bug and the behaviour
that I described could just hide the problem. Commit
851866e22a731141da7e3cbd2550c67c59968959 fixed a problem that could
potentially be the other one.

This means that I'm not entirely sure that we really shouldn't report
zero size data. This is illogical to begin with, but we even have tests
for that:
ok(!on_async, "Returned zero size in response to request complete\n");
I think we should try harder to have a test reporting zero size data
(this may be tricky to write one for Wine tests, but if we could just
observe such occasional notifications, that would be enough). And this
would need more testing with native IE.

This all means that intention of the patch may be right, but it needs
more work.

Thanks,
Jacek



More information about the wine-devel mailing list