mirror of
https://github.com/moparisthebest/curl
synced 2025-03-11 07:39:50 -04:00
corrected bad data re-use and buffer problems
This commit is contained in:
parent
1754d6166c
commit
f353258ff6
@ -183,7 +183,7 @@ int pgrsUpdate(struct UrlData *data)
|
|||||||
struct timeval now;
|
struct timeval now;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
char max5[6][6];
|
char max5[6][10];
|
||||||
double dlpercen=0;
|
double dlpercen=0;
|
||||||
double ulpercen=0;
|
double ulpercen=0;
|
||||||
double total_percen=0;
|
double total_percen=0;
|
||||||
@ -191,12 +191,7 @@ int pgrsUpdate(struct UrlData *data)
|
|||||||
double total_transfer;
|
double total_transfer;
|
||||||
double total_expected_transfer;
|
double total_expected_transfer;
|
||||||
|
|
||||||
#define CURR_TIME 5
|
int nowindex = data->progress.speeder_c% CURR_TIME;
|
||||||
|
|
||||||
static double speeder[ CURR_TIME ];
|
|
||||||
static int speeder_c=0;
|
|
||||||
|
|
||||||
int nowindex = speeder_c% CURR_TIME;
|
|
||||||
int checkindex;
|
int checkindex;
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
@ -241,15 +236,19 @@ int pgrsUpdate(struct UrlData *data)
|
|||||||
/* Let's do the "current speed" thing, which should use the fastest
|
/* Let's do the "current speed" thing, which should use the fastest
|
||||||
of the dl/ul speeds */
|
of the dl/ul speeds */
|
||||||
|
|
||||||
speeder[ nowindex ] = data->progress.downloaded>data->progress.uploaded?
|
data->progress.speeder[ nowindex ] =
|
||||||
|
data->progress.downloaded>data->progress.uploaded?
|
||||||
data->progress.downloaded:data->progress.uploaded;
|
data->progress.downloaded:data->progress.uploaded;
|
||||||
speeder_c++; /* increase */
|
data->progress.speeder_c++; /* increase */
|
||||||
count = ((speeder_c>=CURR_TIME)?CURR_TIME:speeder_c) - 1;
|
count = ((data->progress.speeder_c>=CURR_TIME)?
|
||||||
checkindex = (speeder_c>=CURR_TIME)?speeder_c%CURR_TIME:0;
|
CURR_TIME:data->progress.speeder_c) - 1;
|
||||||
|
checkindex = (data->progress.speeder_c>=CURR_TIME)?
|
||||||
|
data->progress.speeder_c%CURR_TIME:0;
|
||||||
|
|
||||||
/* find out the average speed the last CURR_TIME seconds */
|
/* find out the average speed the last CURR_TIME seconds */
|
||||||
data->progress.current_speed =
|
data->progress.current_speed =
|
||||||
(speeder[nowindex]-speeder[checkindex])/(count?count:1);
|
(data->progress.speeder[nowindex]-
|
||||||
|
data->progress.speeder[checkindex])/(count?count:1);
|
||||||
|
|
||||||
if(data->progress.flags & PGRS_HIDE)
|
if(data->progress.flags & PGRS_HIDE)
|
||||||
return 0;
|
return 0;
|
||||||
@ -284,6 +283,7 @@ int pgrsUpdate(struct UrlData *data)
|
|||||||
total estimate! */
|
total estimate! */
|
||||||
total_estimate = ulestimate>dlestimate?ulestimate:dlestimate;
|
total_estimate = ulestimate>dlestimate?ulestimate:dlestimate;
|
||||||
|
|
||||||
|
|
||||||
/* If we have a total estimate, we can display that and the expected
|
/* If we have a total estimate, we can display that and the expected
|
||||||
time left */
|
time left */
|
||||||
if(total_estimate) {
|
if(total_estimate) {
|
||||||
@ -329,5 +329,5 @@ int pgrsUpdate(struct UrlData *data)
|
|||||||
max5data(data->progress.current_speed, max5[5]) /* current speed */
|
max5data(data->progress.current_speed, max5[5]) /* current speed */
|
||||||
);
|
);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -242,6 +242,11 @@ struct Progress {
|
|||||||
struct timeval t_connect;
|
struct timeval t_connect;
|
||||||
struct timeval t_pretransfer;
|
struct timeval t_pretransfer;
|
||||||
int httpcode;
|
int httpcode;
|
||||||
|
|
||||||
|
#define CURR_TIME 5
|
||||||
|
|
||||||
|
double speeder[ CURR_TIME ];
|
||||||
|
int speeder_c;
|
||||||
};
|
};
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
Loading…
x
Reference in New Issue
Block a user