mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
Use more curl_off_t variables when doing the progress meter calculations and
argument passing and try to convert to double only when providing data to the external world.
This commit is contained in:
parent
50a1853560
commit
0d1fc73f21
@ -242,7 +242,7 @@ CURLcode Curl_file(struct connectdata *conn)
|
||||
it avoids problems with select() and recv() on file descriptors
|
||||
in Winsock */
|
||||
if(fstated)
|
||||
Curl_pgrsSetDownloadSize(data, (double)expected_size);
|
||||
Curl_pgrsSetDownloadSize(data, expected_size);
|
||||
|
||||
if(conn->resume_from)
|
||||
lseek(fd, conn->resume_from, SEEK_SET);
|
||||
@ -268,7 +268,7 @@ CURLcode Curl_file(struct connectdata *conn)
|
||||
if(res)
|
||||
return res;
|
||||
|
||||
Curl_pgrsSetDownloadCounter(data, (double)bytecount);
|
||||
Curl_pgrsSetDownloadCounter(data, bytecount);
|
||||
|
||||
if(Curl_pgrsUpdate(conn))
|
||||
res = CURLE_ABORTED_BY_CALLBACK;
|
||||
|
@ -1821,7 +1821,7 @@ CURLcode Curl_ftp_nextconnect(struct connectdata *conn)
|
||||
/* When we know we're uploading a specified file, we can get the file
|
||||
size prior to the actual upload. */
|
||||
|
||||
Curl_pgrsSetUploadSize(data, (double)data->set.infilesize);
|
||||
Curl_pgrsSetUploadSize(data, data->set.infilesize);
|
||||
|
||||
result = Curl_Transfer(conn, -1, -1, FALSE, NULL, /* no download */
|
||||
SECONDARYSOCKET, bytecountp);
|
||||
|
@ -135,10 +135,10 @@ CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...)
|
||||
*param_doublep = data->progress.t_starttransfer;
|
||||
break;
|
||||
case CURLINFO_SIZE_UPLOAD:
|
||||
*param_doublep = data->progress.uploaded;
|
||||
*param_doublep = (double)data->progress.uploaded;
|
||||
break;
|
||||
case CURLINFO_SIZE_DOWNLOAD:
|
||||
*param_doublep = data->progress.downloaded;
|
||||
*param_doublep = (double)data->progress.downloaded;
|
||||
break;
|
||||
case CURLINFO_SPEED_DOWNLOAD:
|
||||
*param_doublep = data->progress.dlspeed;
|
||||
@ -150,10 +150,10 @@ CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...)
|
||||
*param_longp = data->set.ssl.certverifyresult;
|
||||
break;
|
||||
case CURLINFO_CONTENT_LENGTH_DOWNLOAD:
|
||||
*param_doublep = data->progress.size_dl;
|
||||
*param_doublep = (double)data->progress.size_dl;
|
||||
break;
|
||||
case CURLINFO_CONTENT_LENGTH_UPLOAD:
|
||||
*param_doublep = data->progress.size_ul;
|
||||
*param_doublep = (double)data->progress.size_ul;
|
||||
break;
|
||||
case CURLINFO_REDIRECT_TIME:
|
||||
*param_doublep = data->progress.t_redirect;
|
||||
|
@ -1563,7 +1563,7 @@ CURLcode Curl_http(struct connectdata *conn)
|
||||
add_buffer(req_buffer, "\r\n", 2); /* end of headers */
|
||||
|
||||
/* set the upload size to the progress meter */
|
||||
Curl_pgrsSetUploadSize(data, (double)data->set.infilesize);
|
||||
Curl_pgrsSetUploadSize(data, data->set.infilesize);
|
||||
|
||||
/* this sends the buffer and frees all the buffer resources */
|
||||
result = add_buffer_send(req_buffer, conn,
|
||||
@ -1657,7 +1657,7 @@ CURLcode Curl_http(struct connectdata *conn)
|
||||
add_buffer(req_buffer, "\r\n", 2); /* end of headers! */
|
||||
|
||||
/* set the upload size to the progress meter */
|
||||
Curl_pgrsSetUploadSize(data, (double)data->set.infilesize);
|
||||
Curl_pgrsSetUploadSize(data, data->set.infilesize);
|
||||
|
||||
/* set the pointer to mark that we will send the post body using
|
||||
the read callback */
|
||||
|
@ -165,17 +165,17 @@ void Curl_pgrsStartNow(struct SessionHandle *data)
|
||||
data->progress.start = Curl_tvnow();
|
||||
}
|
||||
|
||||
void Curl_pgrsSetDownloadCounter(struct SessionHandle *data, double size)
|
||||
void Curl_pgrsSetDownloadCounter(struct SessionHandle *data, curl_off_t size)
|
||||
{
|
||||
data->progress.downloaded = size;
|
||||
}
|
||||
|
||||
void Curl_pgrsSetUploadCounter(struct SessionHandle *data, double size)
|
||||
void Curl_pgrsSetUploadCounter(struct SessionHandle *data, curl_off_t size)
|
||||
{
|
||||
data->progress.uploaded = size;
|
||||
}
|
||||
|
||||
void Curl_pgrsSetDownloadSize(struct SessionHandle *data, double size)
|
||||
void Curl_pgrsSetDownloadSize(struct SessionHandle *data, curl_off_t size)
|
||||
{
|
||||
data->progress.size_dl = size;
|
||||
if(size > 0)
|
||||
@ -184,7 +184,7 @@ void Curl_pgrsSetDownloadSize(struct SessionHandle *data, double size)
|
||||
data->progress.flags &= ~PGRS_DL_SIZE_KNOWN;
|
||||
}
|
||||
|
||||
void Curl_pgrsSetUploadSize(struct SessionHandle *data, double size)
|
||||
void Curl_pgrsSetUploadSize(struct SessionHandle *data, curl_off_t size)
|
||||
{
|
||||
data->progress.size_ul = size;
|
||||
if(size > 0)
|
||||
@ -211,8 +211,8 @@ int Curl_pgrsUpdate(struct connectdata *conn)
|
||||
double ulpercen=0;
|
||||
double total_percen=0;
|
||||
|
||||
double total_transfer;
|
||||
double total_expected_transfer;
|
||||
curl_off_t total_transfer;
|
||||
curl_off_t total_expected_transfer;
|
||||
double timespent;
|
||||
|
||||
struct SessionHandle *data = conn->data;
|
||||
@ -259,7 +259,7 @@ int Curl_pgrsUpdate(struct connectdata *conn)
|
||||
|
||||
/* The average download speed this far */
|
||||
data->progress.dlspeed =
|
||||
data->progress.downloaded/(timespent>0.01?timespent:1);
|
||||
data->progress.downloaded/(timespent>0.01?timespent:1.0);
|
||||
|
||||
/* The average upload speed this far */
|
||||
data->progress.ulspeed =
|
||||
@ -324,10 +324,10 @@ int Curl_pgrsUpdate(struct connectdata *conn)
|
||||
/* There's a callback set, so we call that instead of writing
|
||||
anything ourselves. This really is the way to go. */
|
||||
result= data->set.fprogress(data->set.progress_client,
|
||||
data->progress.size_dl,
|
||||
data->progress.downloaded,
|
||||
data->progress.size_ul,
|
||||
data->progress.uploaded);
|
||||
(double)data->progress.size_dl,
|
||||
(double)data->progress.downloaded,
|
||||
(double)data->progress.size_ul,
|
||||
(double)data->progress.uploaded);
|
||||
if(result)
|
||||
failf(data, "Callback aborted");
|
||||
return result;
|
||||
@ -336,15 +336,15 @@ int Curl_pgrsUpdate(struct connectdata *conn)
|
||||
/* Figure out the estimated time of arrival for the upload */
|
||||
if((data->progress.flags & PGRS_UL_SIZE_KNOWN) &&
|
||||
(data->progress.ulspeed > 0)) {
|
||||
ulestimate = data->progress.size_ul / data->progress.ulspeed;
|
||||
ulpercen = (data->progress.uploaded / data->progress.size_ul)*100;
|
||||
ulestimate = (double)data->progress.size_ul / data->progress.ulspeed;
|
||||
ulpercen = ((double)data->progress.uploaded / data->progress.size_ul)*100;
|
||||
}
|
||||
|
||||
/* ... and the download */
|
||||
if((data->progress.flags & PGRS_DL_SIZE_KNOWN) &&
|
||||
(data->progress.dlspeed > 0)) {
|
||||
dlestimate = data->progress.size_dl / data->progress.dlspeed;
|
||||
dlpercen = (data->progress.downloaded / data->progress.size_dl)*100;
|
||||
dlestimate = (double)data->progress.size_dl / data->progress.dlspeed;
|
||||
dlpercen = ((double)data->progress.downloaded / data->progress.size_dl)*100;
|
||||
}
|
||||
|
||||
/* Now figure out which of them that is slower and use for the for
|
||||
@ -378,7 +378,7 @@ int Curl_pgrsUpdate(struct connectdata *conn)
|
||||
|
||||
/* Get the percentage of data transfered so far */
|
||||
if(total_expected_transfer > 0)
|
||||
total_percen=(double)(total_transfer/total_expected_transfer)*100;
|
||||
total_percen=((double)total_transfer/total_expected_transfer)*100;
|
||||
|
||||
fprintf(data->set.err,
|
||||
"\r%3d %s %3d %s %3d %s %s %s %s %s %s %s",
|
||||
|
@ -40,10 +40,10 @@ typedef enum {
|
||||
|
||||
void Curl_pgrsDone(struct connectdata *);
|
||||
void Curl_pgrsStartNow(struct SessionHandle *data);
|
||||
void Curl_pgrsSetDownloadSize(struct SessionHandle *data, double size);
|
||||
void Curl_pgrsSetUploadSize(struct SessionHandle *data, double size);
|
||||
void Curl_pgrsSetDownloadCounter(struct SessionHandle *data, double size);
|
||||
void Curl_pgrsSetUploadCounter(struct SessionHandle *data, double size);
|
||||
void Curl_pgrsSetDownloadSize(struct SessionHandle *data, curl_off_t size);
|
||||
void Curl_pgrsSetUploadSize(struct SessionHandle *data, curl_off_t size);
|
||||
void Curl_pgrsSetDownloadCounter(struct SessionHandle *data, curl_off_t size);
|
||||
void Curl_pgrsSetUploadCounter(struct SessionHandle *data, curl_off_t size);
|
||||
int Curl_pgrsUpdate(struct connectdata *);
|
||||
void Curl_pgrsResetTimes(struct SessionHandle *data);
|
||||
void Curl_pgrsTime(struct SessionHandle *data, timerid timer);
|
||||
|
@ -985,7 +985,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
||||
|
||||
k->bytecount += nread;
|
||||
|
||||
Curl_pgrsSetDownloadCounter(data, (double)k->bytecount);
|
||||
Curl_pgrsSetDownloadCounter(data, k->bytecount);
|
||||
|
||||
if(!conn->bits.chunk && (nread || k->badheader)) {
|
||||
/* If this is chunky transfer, it was already written */
|
||||
@ -1188,7 +1188,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
||||
}
|
||||
|
||||
k->writebytecount += bytes_written;
|
||||
Curl_pgrsSetUploadCounter(data, (double)k->writebytecount);
|
||||
Curl_pgrsSetUploadCounter(data, k->writebytecount);
|
||||
|
||||
} while(!writedone); /* loop until we're done writing! */
|
||||
|
||||
@ -1306,7 +1306,7 @@ CURLcode Curl_readwrite_init(struct connectdata *conn)
|
||||
if (!conn->bits.getheader) {
|
||||
k->header = FALSE;
|
||||
if(conn->size > 0)
|
||||
Curl_pgrsSetDownloadSize(data, (double)conn->size);
|
||||
Curl_pgrsSetDownloadSize(data, conn->size);
|
||||
}
|
||||
/* we want header and/or body, if neither then don't do this! */
|
||||
if(conn->bits.getheader || !data->set.no_body) {
|
||||
|
@ -604,10 +604,10 @@ struct PureInfo {
|
||||
struct Progress {
|
||||
long lastshow; /* time() of the last displayed progress meter or NULL to
|
||||
force redraw at next call */
|
||||
double size_dl;
|
||||
double size_ul;
|
||||
double downloaded;
|
||||
double uploaded;
|
||||
curl_off_t size_dl; /* total expected size */
|
||||
curl_off_t size_ul; /* total expected size */
|
||||
curl_off_t downloaded; /* transfered so far */
|
||||
curl_off_t uploaded; /* transfered so far */
|
||||
|
||||
double current_speed; /* uses the currently fastest transfer */
|
||||
|
||||
@ -630,7 +630,7 @@ struct Progress {
|
||||
struct timeval t_startsingle;
|
||||
#define CURR_TIME (5+1) /* 6 entries for 5 seconds */
|
||||
|
||||
double speeder[ CURR_TIME ];
|
||||
curl_off_t speeder[ CURR_TIME ];
|
||||
struct timeval speeder_time[ CURR_TIME ];
|
||||
int speeder_c;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user