mirror of
https://github.com/moparisthebest/curl
synced 2024-11-10 11:35:07 -05:00
made the speedcheck actually work again
This commit is contained in:
parent
f6163b375f
commit
135cc036aa
@ -174,6 +174,7 @@ _Transfer(struct connectdata *c_conn)
|
|||||||
#define KEEP_WRITE 2
|
#define KEEP_WRITE 2
|
||||||
|
|
||||||
pgrsTime(data, TIMER_PRETRANSFER);
|
pgrsTime(data, TIMER_PRETRANSFER);
|
||||||
|
speedinit(data);
|
||||||
|
|
||||||
if (!conn->getheader) {
|
if (!conn->getheader) {
|
||||||
header = FALSE;
|
header = FALSE;
|
||||||
|
@ -50,21 +50,24 @@
|
|||||||
#include "sendf.h"
|
#include "sendf.h"
|
||||||
#include "speedcheck.h"
|
#include "speedcheck.h"
|
||||||
|
|
||||||
|
void speedinit(struct UrlData *data)
|
||||||
|
{
|
||||||
|
memset(&data->keeps_speed, 0, sizeof(struct timeval));
|
||||||
|
}
|
||||||
|
|
||||||
CURLcode speedcheck(struct UrlData *data,
|
CURLcode speedcheck(struct UrlData *data,
|
||||||
struct timeval now)
|
struct timeval now)
|
||||||
{
|
{
|
||||||
static struct timeval keeps_speed;
|
if((data->progress.current_speed >= 0) &&
|
||||||
|
|
||||||
if((data->current_speed >= 0) &&
|
|
||||||
data->low_speed_time &&
|
data->low_speed_time &&
|
||||||
(tvlong(keeps_speed) != 0) &&
|
(tvlong(data->keeps_speed) != 0) &&
|
||||||
(data->current_speed < data->low_speed_limit)) {
|
(data->progress.current_speed < data->low_speed_limit)) {
|
||||||
|
|
||||||
/* We are now below the "low speed limit". If we are below it
|
/* We are now below the "low speed limit". If we are below it
|
||||||
for "low speed time" seconds we consider that enough reason
|
for "low speed time" seconds we consider that enough reason
|
||||||
to abort the download. */
|
to abort the download. */
|
||||||
|
|
||||||
if( tvdiff(now, keeps_speed) > data->low_speed_time) {
|
if( tvdiff(now, data->keeps_speed) > data->low_speed_time) {
|
||||||
/* we have been this slow for long enough, now die */
|
/* we have been this slow for long enough, now die */
|
||||||
failf(data,
|
failf(data,
|
||||||
"Operation too slow. "
|
"Operation too slow. "
|
||||||
@ -76,7 +79,7 @@ CURLcode speedcheck(struct UrlData *data,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* we keep up the required speed all right */
|
/* we keep up the required speed all right */
|
||||||
keeps_speed = now;
|
data->keeps_speed = now;
|
||||||
}
|
}
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
|
|
||||||
#include "timeval.h"
|
#include "timeval.h"
|
||||||
|
|
||||||
|
void speedinit(struct UrlData *data);
|
||||||
CURLcode speedcheck(struct UrlData *data,
|
CURLcode speedcheck(struct UrlData *data,
|
||||||
struct timeval now);
|
struct timeval now);
|
||||||
|
|
||||||
|
@ -503,6 +503,8 @@ struct UrlData {
|
|||||||
#ifdef KRB4
|
#ifdef KRB4
|
||||||
FILE *cmdchannel;
|
FILE *cmdchannel;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
struct timeval keeps_speed; /* this should be request-specific */
|
||||||
};
|
};
|
||||||
|
|
||||||
#define LIBCURL_NAME "libcurl"
|
#define LIBCURL_NAME "libcurl"
|
||||||
|
Loading…
Reference in New Issue
Block a user