aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2011-03-12 23:05:11 +0100
committerDaniel Stenberg <daniel@haxx.se>2011-03-12 23:05:11 +0100
commita07a865d5dff76fdaed2f2c6373f89fde73037f8 (patch)
treec5abb1789e919d9dc48dfe8e8c765c374e4d3eb7 /lib
parentcccba72920ace26f1ecdf496546a2441304df410 (diff)
readwrite_upload: stop upload at file size
As we know how much to send, we can and should stop once we've sent that much data as it avoids having to rely on other mechanisms to detect the end. This is one of the problems detected by test 582. Reported by: Henry Ludemann <misc@hl.id.au>
Diffstat (limited to 'lib')
-rw-r--r--lib/transfer.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/transfer.c b/lib/transfer.c
index b3e6e9935..63ab5c4e9 100644
--- a/lib/transfer.c
+++ b/lib/transfer.c
@@ -946,6 +946,14 @@ static CURLcode readwrite_upload(struct SessionHandle *data,
Curl_debug(data, CURLINFO_DATA_OUT, data->req.upload_fromhere,
(size_t)bytes_written, conn);
+ k->writebytecount += bytes_written;
+
+ if(k->writebytecount == data->set.infilesize) {
+ /* we have sent all data we were supposed to */
+ k->upload_done = TRUE;
+ infof(data, "We are completely uploaded and fine\n");
+ }
+
if(data->req.upload_present != bytes_written) {
/* we only wrote a part of the buffer (if anything), deal with it! */
@@ -967,7 +975,6 @@ static CURLcode readwrite_upload(struct SessionHandle *data,
}
}
- k->writebytecount += bytes_written;
Curl_pgrsSetUploadCounter(data, k->writebytecount);
} while(0); /* just to break out from! */