Prevent rewinding unless pipelining.
See http://curl.haxx.se/mail/lib-2009-12/0107.html
This commit is contained in:
parent
2fc1752d6e
commit
463d2d395c
@ -383,6 +383,8 @@ static int data_pending(const struct connectdata *conn)
|
|||||||
static void read_rewind(struct connectdata *conn,
|
static void read_rewind(struct connectdata *conn,
|
||||||
size_t thismuch)
|
size_t thismuch)
|
||||||
{
|
{
|
||||||
|
DEBUGASSERT(conn->read_pos >= thismuch);
|
||||||
|
|
||||||
conn->read_pos -= thismuch;
|
conn->read_pos -= thismuch;
|
||||||
conn->bits.stream_was_rewound = TRUE;
|
conn->bits.stream_was_rewound = TRUE;
|
||||||
|
|
||||||
@ -634,18 +636,21 @@ static CURLcode readwrite_data(struct SessionHandle *data,
|
|||||||
|
|
||||||
if((-1 != k->maxdownload) &&
|
if((-1 != k->maxdownload) &&
|
||||||
(k->bytecount + nread >= 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 */
|
if(conn->data->multi && Curl_multi_canPipeline(conn->data->multi)) {
|
||||||
size_t excess = (size_t)(k->bytecount + nread - k->maxdownload);
|
/* The 'excess' amount below can't be more than BUFSIZE which
|
||||||
if(excess > 0 && !k->ignorebody) {
|
always will fit in a size_t */
|
||||||
infof(data,
|
size_t excess = (size_t)(k->bytecount + nread - k->maxdownload);
|
||||||
"Rewinding stream by : %d"
|
if(excess > 0 && !k->ignorebody) {
|
||||||
" bytes on url %s (size = %" FORMAT_OFF_T
|
infof(data,
|
||||||
", maxdownload = %" FORMAT_OFF_T
|
"Rewinding stream by : %d"
|
||||||
", bytecount = %" FORMAT_OFF_T ", nread = %d)\n",
|
" bytes on url %s (size = %" FORMAT_OFF_T
|
||||||
excess, data->state.path,
|
", maxdownload = %" FORMAT_OFF_T
|
||||||
k->size, k->maxdownload, k->bytecount, nread);
|
", bytecount = %" FORMAT_OFF_T ", nread = %d)\n",
|
||||||
read_rewind(conn, excess);
|
excess, data->state.path,
|
||||||
|
k->size, k->maxdownload, k->bytecount, nread);
|
||||||
|
read_rewind(conn, excess);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nread = (ssize_t) (k->maxdownload - k->bytecount);
|
nread = (ssize_t) (k->maxdownload - k->bytecount);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user