curl: Fix hang reading from slow connections
authorMatthew Booth <mbooth@redhat.com>
Tue, 29 Apr 2014 15:03:32 +0000 (16:03 +0100)
committerKevin Wolf <kwolf@redhat.com>
Wed, 30 Apr 2014 14:34:21 +0000 (16:34 +0200)
When receiving a new aio read request, we first look for an existing
transaction whose range will cover the read request by the time it
completes. However, we weren't checking that the existing transaction
was still active. If it had timed out, we were adding the request to a
transaction which would never complete and had already been cancelled,
resulting in a hang.

Signed-off-by: Matthew Booth <mbooth@redhat.com>
Tested-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/curl.c

index 16e7db8eea6a0b4f1b6308f25b44868dbb6585b5..d2f1084b913dbf1615949b4bd8cb9d9e677bbcf4 100644 (file)
@@ -220,7 +220,8 @@ static int curl_find_buf(BDRVCURLState *s, size_t start, size_t len,
         }
 
         // Wait for unfinished chunks
-        if ((start >= state->buf_start) &&
+        if (state->in_use &&
+            (start >= state->buf_start) &&
             (start <= buf_fend) &&
             (end >= state->buf_start) &&
             (end <= buf_fend))