aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2009-12-11 18:41:29 +0000
committerYang Tse <yangsita@gmail.com>2009-12-11 18:41:29 +0000
commit463d2d395caaafc557590a09aa01db28527e560f (patch)
tree731d3f41bf486fbfc9ac85af8cc8e2d869ebc0bd /lib
parent2fc1752d6e978995ae04cc36525f76fd57a4ae09 (diff)
Prevent rewinding unless pipelining.
See http://curl.haxx.se/mail/lib-2009-12/0107.html
Diffstat (limited to 'lib')
-rw-r--r--lib/transfer.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/lib/transfer.c b/lib/transfer.c
index 613cc5117..a18ad8729 100644
--- a/lib/transfer.c
+++ b/lib/transfer.c
@@ -383,6 +383,8 @@ static int data_pending(const struct connectdata *conn)
static void read_rewind(struct connectdata *conn,
size_t thismuch)
{
+ DEBUGASSERT(conn->read_pos >= thismuch);
+
conn->read_pos -= thismuch;
conn->bits.stream_was_rewound = TRUE;
@@ -634,18 +636,21 @@ static CURLcode readwrite_data(struct SessionHandle *data,
if((-1 != k->maxdownload) &&
(k->bytecount + nread >= k->maxdownload)) {
- /* The 'excess' amount below can't be more than BUFSIZE which
- always will fit in a size_t */
- size_t excess = (size_t)(k->bytecount + nread - k->maxdownload);
- if(excess > 0 && !k->ignorebody) {
- infof(data,
- "Rewinding stream by : %d"
- " bytes on url %s (size = %" FORMAT_OFF_T
- ", maxdownload = %" FORMAT_OFF_T
- ", bytecount = %" FORMAT_OFF_T ", nread = %d)\n",
- excess, data->state.path,
- k->size, k->maxdownload, k->bytecount, nread);
- read_rewind(conn, excess);
+
+ if(conn->data->multi && Curl_multi_canPipeline(conn->data->multi)) {
+ /* The 'excess' amount below can't be more than BUFSIZE which
+ always will fit in a size_t */
+ size_t excess = (size_t)(k->bytecount + nread - k->maxdownload);
+ if(excess > 0 && !k->ignorebody) {
+ infof(data,
+ "Rewinding stream by : %d"
+ " bytes on url %s (size = %" FORMAT_OFF_T
+ ", maxdownload = %" FORMAT_OFF_T
+ ", bytecount = %" FORMAT_OFF_T ", nread = %d)\n",
+ excess, data->state.path,
+ k->size, k->maxdownload, k->bytecount, nread);
+ read_rewind(conn, excess);
+ }
}
nread = (ssize_t) (k->maxdownload - k->bytecount);