From ae1912cb0d494b48d514d937826c9fe83ec96c4d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 29 Dec 1999 14:20:26 +0000 Subject: Initial revision --- lib/speedcheck.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 lib/speedcheck.c (limited to 'lib/speedcheck.c') diff --git a/lib/speedcheck.c b/lib/speedcheck.c new file mode 100644 index 000000000..5647b50e2 --- /dev/null +++ b/lib/speedcheck.c @@ -0,0 +1,81 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * The contents of this file are subject to the Mozilla Public License + * Version 1.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the + * License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Curl. + * + * The Initial Developer of the Original Code is Daniel Stenberg. + * + * Portions created by the Initial Developer are Copyright (C) 1998. + * All Rights Reserved. + * + * ------------------------------------------------------------ + * Main author: + * - Daniel Stenberg + * + * http://curl.haxx.nu + * + * $Source$ + * $Revision$ + * $Date$ + * $Author$ + * $State$ + * $Locker$ + * + * ------------------------------------------------------------ + ****************************************************************************/ + +#include +#if defined(__MINGW32__) +#include +#endif + +#include +#include "urldata.h" +#include "sendf.h" +#include "speedcheck.h" + +UrgError speedcheck(struct UrlData *data, + struct timeval now) +{ + static struct timeval keeps_speed; + + if((data->current_speed >= 0) && + data->low_speed_time && + (tvlong(keeps_speed) != 0) && + (data->current_speed < data->low_speed_limit)) { + + /* We are now below the "low speed limit". If we are below it + for "low speed time" seconds we consider that enough reason + to abort the download. */ + + if( tvdiff(now, keeps_speed) > data->low_speed_time) { + /* we have been this slow for long enough, now die */ + failf(data, + "Operation too slow. " + "Less than %d bytes/sec transfered the last %d seconds", + data->low_speed_limit, + data->low_speed_time); + return URG_OPERATION_TIMEOUTED; + } + } + else { + /* we keep up the required speed all right */ + keeps_speed = now; + } + return URG_OK; +} + -- cgit v1.2.1 From 96dde76b99897352aa3d0877a0b621a9e605733e Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 22 May 2000 14:12:12 +0000 Subject: moved here from the newlib branch --- lib/speedcheck.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/speedcheck.c') diff --git a/lib/speedcheck.c b/lib/speedcheck.c index 5647b50e2..48772b39c 100644 --- a/lib/speedcheck.c +++ b/lib/speedcheck.c @@ -48,7 +48,7 @@ #include "sendf.h" #include "speedcheck.h" -UrgError speedcheck(struct UrlData *data, +CURLcode speedcheck(struct UrlData *data, struct timeval now) { static struct timeval keeps_speed; @@ -69,13 +69,13 @@ UrgError speedcheck(struct UrlData *data, "Less than %d bytes/sec transfered the last %d seconds", data->low_speed_limit, data->low_speed_time); - return URG_OPERATION_TIMEOUTED; + return CURLE_OPERATION_TIMEOUTED; } } else { /* we keep up the required speed all right */ keeps_speed = now; } - return URG_OK; + return CURLE_OK; } -- cgit v1.2.1 From 1ef3600a0731fef8f59563a1e49981f1b64b9746 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 20 Jun 2000 15:31:26 +0000 Subject: haxx.nu => haxx.se --- lib/speedcheck.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/speedcheck.c') diff --git a/lib/speedcheck.c b/lib/speedcheck.c index 48772b39c..36fb75c03 100644 --- a/lib/speedcheck.c +++ b/lib/speedcheck.c @@ -24,9 +24,9 @@ * * ------------------------------------------------------------ * Main author: - * - Daniel Stenberg + * - Daniel Stenberg * - * http://curl.haxx.nu + * http://curl.haxx.se * * $Source$ * $Revision$ -- cgit v1.2.1 From b6e18f2f665f16910c04cb52bdc7b90270ab7c9b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 24 Aug 2000 14:26:33 +0000 Subject: #include "setup.h" moved first of all includes --- lib/speedcheck.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/speedcheck.c') diff --git a/lib/speedcheck.c b/lib/speedcheck.c index 36fb75c03..125f077ac 100644 --- a/lib/speedcheck.c +++ b/lib/speedcheck.c @@ -38,6 +38,8 @@ * ------------------------------------------------------------ ****************************************************************************/ +#include "setup.h" + #include #if defined(__MINGW32__) #include -- cgit v1.2.1 From 135cc036aa1425c52c3cf90176158c19e109cb9b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 17 Oct 2000 14:53:03 +0000 Subject: made the speedcheck actually work again --- lib/speedcheck.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'lib/speedcheck.c') diff --git a/lib/speedcheck.c b/lib/speedcheck.c index 125f077ac..d3d33e562 100644 --- a/lib/speedcheck.c +++ b/lib/speedcheck.c @@ -50,21 +50,24 @@ #include "sendf.h" #include "speedcheck.h" +void speedinit(struct UrlData *data) +{ + memset(&data->keeps_speed, 0, sizeof(struct timeval)); +} + CURLcode speedcheck(struct UrlData *data, struct timeval now) { - static struct timeval keeps_speed; - - if((data->current_speed >= 0) && + if((data->progress.current_speed >= 0) && data->low_speed_time && - (tvlong(keeps_speed) != 0) && - (data->current_speed < data->low_speed_limit)) { + (tvlong(data->keeps_speed) != 0) && + (data->progress.current_speed < data->low_speed_limit)) { /* We are now below the "low speed limit". If we are below it for "low speed time" seconds we consider that enough reason 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 */ failf(data, "Operation too slow. " @@ -76,7 +79,7 @@ CURLcode speedcheck(struct UrlData *data, } else { /* we keep up the required speed all right */ - keeps_speed = now; + data->keeps_speed = now; } return CURLE_OK; } -- cgit v1.2.1 From 24dee483e9e925c2ab79dd582f70c9a55ab9ba4d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 3 Jan 2001 09:29:33 +0000 Subject: dual-license fix --- lib/speedcheck.c | 39 +++++++++++---------------------------- 1 file changed, 11 insertions(+), 28 deletions(-) (limited to 'lib/speedcheck.c') diff --git a/lib/speedcheck.c b/lib/speedcheck.c index d3d33e562..0578ccc22 100644 --- a/lib/speedcheck.c +++ b/lib/speedcheck.c @@ -5,38 +5,21 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * The contents of this file are subject to the Mozilla Public License - * Version 1.0 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ + * Copyright (C) 2000, Daniel Stenberg, , et al. * - * Software distributed under the License is distributed on an "AS IS" - * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the - * License for the specific language governing rights and limitations - * under the License. + * In order to be useful for every potential user, curl and libcurl are + * dual-licensed under the MPL and the MIT/X-derivate licenses. * - * The Original Code is Curl. + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the MPL or the MIT/X-derivate + * licenses. You may pick one of these licenses. * - * The Initial Developer of the Original Code is Daniel Stenberg. + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. * - * Portions created by the Initial Developer are Copyright (C) 1998. - * All Rights Reserved. - * - * ------------------------------------------------------------ - * Main author: - * - Daniel Stenberg - * - * http://curl.haxx.se - * - * $Source$ - * $Revision$ - * $Date$ - * $Author$ - * $State$ - * $Locker$ - * - * ------------------------------------------------------------ - ****************************************************************************/ + * $Id$ + *****************************************************************************/ #include "setup.h" -- cgit v1.2.1 From 4031104404c6ceed5e57134125dcdb6cac51c564 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 5 Jan 2001 10:11:41 +0000 Subject: Internal symbols that aren't static are now prefixed with 'Curl_' --- lib/speedcheck.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/speedcheck.c') diff --git a/lib/speedcheck.c b/lib/speedcheck.c index 0578ccc22..17e9d90d7 100644 --- a/lib/speedcheck.c +++ b/lib/speedcheck.c @@ -33,24 +33,24 @@ #include "sendf.h" #include "speedcheck.h" -void speedinit(struct UrlData *data) +void Curl_speedinit(struct UrlData *data) { memset(&data->keeps_speed, 0, sizeof(struct timeval)); } -CURLcode speedcheck(struct UrlData *data, - struct timeval now) +CURLcode Curl_speedcheck(struct UrlData *data, + struct timeval now) { if((data->progress.current_speed >= 0) && data->low_speed_time && - (tvlong(data->keeps_speed) != 0) && + (Curl_tvlong(data->keeps_speed) != 0) && (data->progress.current_speed < data->low_speed_limit)) { /* We are now below the "low speed limit". If we are below it for "low speed time" seconds we consider that enough reason to abort the download. */ - if( tvdiff(now, data->keeps_speed) > data->low_speed_time) { + if( Curl_tvdiff(now, data->keeps_speed) > data->low_speed_time) { /* we have been this slow for long enough, now die */ failf(data, "Operation too slow. " -- cgit v1.2.1 From beb8761b224e7170141365fd10644b0c7d1f0c88 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 9 Mar 2001 15:14:51 +0000 Subject: #include removed a warning --- lib/speedcheck.c | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/speedcheck.c') diff --git a/lib/speedcheck.c b/lib/speedcheck.c index 17e9d90d7..3112d2575 100644 --- a/lib/speedcheck.c +++ b/lib/speedcheck.c @@ -24,6 +24,7 @@ #include "setup.h" #include +#include #if defined(__MINGW32__) #include #endif -- cgit v1.2.1 From 0ece1b5c34c049a3226f7dd793cf75e470c46e4d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 30 Aug 2001 22:48:34 +0000 Subject: Major rename and redesign of the internal "backbone" structs. Details will be posted in a minute to the libcurl list. --- lib/speedcheck.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'lib/speedcheck.c') diff --git a/lib/speedcheck.c b/lib/speedcheck.c index 3112d2575..274ceb108 100644 --- a/lib/speedcheck.c +++ b/lib/speedcheck.c @@ -34,36 +34,36 @@ #include "sendf.h" #include "speedcheck.h" -void Curl_speedinit(struct UrlData *data) +void Curl_speedinit(struct SessionHandle *data) { - memset(&data->keeps_speed, 0, sizeof(struct timeval)); + memset(&data->state.keeps_speed, 0, sizeof(struct timeval)); } -CURLcode Curl_speedcheck(struct UrlData *data, +CURLcode Curl_speedcheck(struct SessionHandle *data, struct timeval now) { if((data->progress.current_speed >= 0) && - data->low_speed_time && - (Curl_tvlong(data->keeps_speed) != 0) && - (data->progress.current_speed < data->low_speed_limit)) { + data->set.low_speed_time && + (Curl_tvlong(data->state.keeps_speed) != 0) && + (data->progress.current_speed < data->set.low_speed_limit)) { /* We are now below the "low speed limit". If we are below it for "low speed time" seconds we consider that enough reason to abort the download. */ - if( Curl_tvdiff(now, data->keeps_speed) > data->low_speed_time) { + if( Curl_tvdiff(now, data->state.keeps_speed) > data->set.low_speed_time) { /* we have been this slow for long enough, now die */ failf(data, "Operation too slow. " "Less than %d bytes/sec transfered the last %d seconds", - data->low_speed_limit, - data->low_speed_time); + data->set.low_speed_limit, + data->set.low_speed_time); return CURLE_OPERATION_TIMEOUTED; } } else { /* we keep up the required speed all right */ - data->keeps_speed = now; + data->state.keeps_speed = now; } return CURLE_OK; } -- cgit v1.2.1 From 6147879837a53d22c9be04e7a4fc315a297ba2b3 Mon Sep 17 00:00:00 2001 From: Sterling Hughes Date: Fri, 7 Sep 2001 04:01:32 +0000 Subject: Added formatting sections for emacs and vim --- lib/speedcheck.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/speedcheck.c') diff --git a/lib/speedcheck.c b/lib/speedcheck.c index 274ceb108..465a2aa0f 100644 --- a/lib/speedcheck.c +++ b/lib/speedcheck.c @@ -68,3 +68,10 @@ CURLcode Curl_speedcheck(struct SessionHandle *data, return CURLE_OK; } +/* + * local variables: + * eval: (load-file "../curl-mode.el") + * end: + * vim600: et sw=2 ts=2 sts=2 tw=78 fdm=marker + * vim<600: et sw=2 ts=2 sts=2 tw=78 + */ -- cgit v1.2.1 From 8e91d5de8e4e17ce3d4936cc91171d09726e7bb3 Mon Sep 17 00:00:00 2001 From: Sterling Hughes Date: Thu, 11 Oct 2001 09:32:19 +0000 Subject: looks nicer and is better compatible with older vim versions --- lib/speedcheck.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/speedcheck.c') diff --git a/lib/speedcheck.c b/lib/speedcheck.c index 465a2aa0f..3860d10d6 100644 --- a/lib/speedcheck.c +++ b/lib/speedcheck.c @@ -72,6 +72,6 @@ CURLcode Curl_speedcheck(struct SessionHandle *data, * local variables: * eval: (load-file "../curl-mode.el") * end: - * vim600: et sw=2 ts=2 sts=2 tw=78 fdm=marker - * vim<600: et sw=2 ts=2 sts=2 tw=78 + * vim600: fdm=marker + * vim: et sw=2 ts=2 sts=2 tw=78 */ -- cgit v1.2.1 From 532bca41e59e10a86c356058831cf046a3ba78c9 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 12 Oct 2001 12:32:20 +0000 Subject: Curl_tvdiff() now returns a millisecond diff, no double like before --- lib/speedcheck.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/speedcheck.c') diff --git a/lib/speedcheck.c b/lib/speedcheck.c index 3860d10d6..0b393c0c7 100644 --- a/lib/speedcheck.c +++ b/lib/speedcheck.c @@ -51,7 +51,8 @@ CURLcode Curl_speedcheck(struct SessionHandle *data, for "low speed time" seconds we consider that enough reason to abort the download. */ - if( Curl_tvdiff(now, data->state.keeps_speed) > data->set.low_speed_time) { + if( (Curl_tvdiff(now, data->state.keeps_speed)/1000) > + data->set.low_speed_time) { /* we have been this slow for long enough, now die */ failf(data, "Operation too slow. " -- cgit v1.2.1 From 974f314f5785156af6983675aeb28313cc8ba2ea Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 19 Mar 2002 07:54:55 +0000 Subject: copyright string (year) update --- lib/speedcheck.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/speedcheck.c') diff --git a/lib/speedcheck.c b/lib/speedcheck.c index 0b393c0c7..5f67535ef 100644 --- a/lib/speedcheck.c +++ b/lib/speedcheck.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2000, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2002, Daniel Stenberg, , et al. * * In order to be useful for every potential user, curl and libcurl are * dual-licensed under the MPL and the MIT/X-derivate licenses. -- cgit v1.2.1 From ba4e69bebc8f7f32f3bc7faa1e13e7580754075b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 3 Sep 2002 11:52:59 +0000 Subject: updated source code boilerplate/header --- lib/speedcheck.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'lib/speedcheck.c') diff --git a/lib/speedcheck.c b/lib/speedcheck.c index 5f67535ef..3d3a3e7eb 100644 --- a/lib/speedcheck.c +++ b/lib/speedcheck.c @@ -1,4 +1,4 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | @@ -7,19 +7,19 @@ * * Copyright (C) 1998 - 2002, Daniel Stenberg, , et al. * - * In order to be useful for every potential user, curl and libcurl are - * dual-licensed under the MPL and the MIT/X-derivate licenses. - * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * * You may opt to use, copy, modify, merge, publish, distribute and/or sell * copies of the Software, and permit persons to whom the Software is - * furnished to do so, under the terms of the MPL or the MIT/X-derivate - * licenses. You may pick one of these licenses. + * furnished to do so, under the terms of the COPYING file. * * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * KIND, either express or implied. * * $Id$ - *****************************************************************************/ + ***************************************************************************/ #include "setup.h" -- cgit v1.2.1 From f26a338a54e04d0a6907f5d2479d8b0fa9daf297 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 16 Jan 2003 21:08:12 +0000 Subject: copyright year update in the source header --- lib/speedcheck.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/speedcheck.c') diff --git a/lib/speedcheck.c b/lib/speedcheck.c index 3d3a3e7eb..e57791509 100644 --- a/lib/speedcheck.c +++ b/lib/speedcheck.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2002, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2003, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms -- cgit v1.2.1 From a7c72b7abf1213c471f3fd11e6b8e3a37d526f60 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 29 Jan 2003 10:14:20 +0000 Subject: removed the local variables for emacs and vim, use the new sample.emacs way for emacs, and vim users should provide a similar non-polluting style --- lib/speedcheck.c | 8 -------- 1 file changed, 8 deletions(-) (limited to 'lib/speedcheck.c') diff --git a/lib/speedcheck.c b/lib/speedcheck.c index e57791509..f61443848 100644 --- a/lib/speedcheck.c +++ b/lib/speedcheck.c @@ -68,11 +68,3 @@ CURLcode Curl_speedcheck(struct SessionHandle *data, } return CURLE_OK; } - -/* - * local variables: - * eval: (load-file "../curl-mode.el") - * end: - * vim600: fdm=marker - * vim: et sw=2 ts=2 sts=2 tw=78 - */ -- cgit v1.2.1 From 749f5387c19449209615b282ac738032f2a890e7 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 14 Oct 2003 12:00:45 +0000 Subject: Gisle Vanem's IPv6-on-Windows patch applied! --- lib/speedcheck.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'lib/speedcheck.c') diff --git a/lib/speedcheck.c b/lib/speedcheck.c index f61443848..c7a6ae405 100644 --- a/lib/speedcheck.c +++ b/lib/speedcheck.c @@ -25,9 +25,6 @@ #include #include -#if defined(__MINGW32__) -#include -#endif #include #include "urldata.h" -- cgit v1.2.1 From 053f6c85efd0bf698f73343989474d672d0563a8 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 7 Jan 2004 09:19:33 +0000 Subject: updated year in the copyright string --- lib/speedcheck.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/speedcheck.c') diff --git a/lib/speedcheck.c b/lib/speedcheck.c index c7a6ae405..b8b45cad1 100644 --- a/lib/speedcheck.c +++ b/lib/speedcheck.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2003, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms -- cgit v1.2.1 From 39af394a1c3ae1d8ac71ad263a7c524988702c2e Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 6 Oct 2004 07:50:18 +0000 Subject: removed tabs and trailing whitespace from source --- lib/speedcheck.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'lib/speedcheck.c') diff --git a/lib/speedcheck.c b/lib/speedcheck.c index b8b45cad1..273cacb5a 100644 --- a/lib/speedcheck.c +++ b/lib/speedcheck.c @@ -1,8 +1,8 @@ /*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. @@ -10,7 +10,7 @@ * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms * are also available at http://curl.haxx.se/docs/copyright.html. - * + * * You may opt to use, copy, modify, merge, publish, distribute and/or sell * copies of the Software, and permit persons to whom the Software is * furnished to do so, under the terms of the COPYING file. @@ -47,15 +47,15 @@ CURLcode Curl_speedcheck(struct SessionHandle *data, /* We are now below the "low speed limit". If we are below it for "low speed time" seconds we consider that enough reason to abort the download. */ - + if( (Curl_tvdiff(now, data->state.keeps_speed)/1000) > data->set.low_speed_time) { /* we have been this slow for long enough, now die */ failf(data, - "Operation too slow. " - "Less than %d bytes/sec transfered the last %d seconds", - data->set.low_speed_limit, - data->set.low_speed_time); + "Operation too slow. " + "Less than %d bytes/sec transfered the last %d seconds", + data->set.low_speed_limit, + data->set.low_speed_time); return CURLE_OPERATION_TIMEOUTED; } } -- cgit v1.2.1 From 686d90745be4417127050ad4b36d0a5403def200 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 10 Apr 2006 15:00:53 +0000 Subject: First curl_multi_socket() commit. Should primarily be considered as an internal code rearrange to fit the future better. --- lib/speedcheck.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/speedcheck.c') diff --git a/lib/speedcheck.c b/lib/speedcheck.c index 273cacb5a..5ee009ee2 100644 --- a/lib/speedcheck.c +++ b/lib/speedcheck.c @@ -29,6 +29,7 @@ #include #include "urldata.h" #include "sendf.h" +#include "multiif.h" #include "speedcheck.h" void Curl_speedinit(struct SessionHandle *data) @@ -43,13 +44,13 @@ CURLcode Curl_speedcheck(struct SessionHandle *data, data->set.low_speed_time && (Curl_tvlong(data->state.keeps_speed) != 0) && (data->progress.current_speed < data->set.low_speed_limit)) { + long howlong = Curl_tvdiff(now, data->state.keeps_speed); /* We are now below the "low speed limit". If we are below it for "low speed time" seconds we consider that enough reason to abort the download. */ - if( (Curl_tvdiff(now, data->state.keeps_speed)/1000) > - data->set.low_speed_time) { + if( (howlong/1000) > data->set.low_speed_time) { /* we have been this slow for long enough, now die */ failf(data, "Operation too slow. " @@ -58,6 +59,7 @@ CURLcode Curl_speedcheck(struct SessionHandle *data, data->set.low_speed_time); return CURLE_OPERATION_TIMEOUTED; } + Curl_expire(data, howlong); } else { /* we keep up the required speed all right */ -- cgit v1.2.1 From e3a61fba52fc3145594e9b9e14f16802d5e32068 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 17 Oct 2006 09:05:44 +0000 Subject: make the low_speed check set the expire timer so that it has a chance to work even when using curl_multi_socket() or even using the multi_perform() when relying on multi_timeout() to be good. --- lib/speedcheck.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/speedcheck.c') diff --git a/lib/speedcheck.c b/lib/speedcheck.c index 5ee009ee2..adda8a963 100644 --- a/lib/speedcheck.c +++ b/lib/speedcheck.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2006, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -64,6 +64,12 @@ CURLcode Curl_speedcheck(struct SessionHandle *data, else { /* we keep up the required speed all right */ data->state.keeps_speed = now; + + if(data->set.low_speed_limit) + /* if there is a low speed limit enabled, we set the expire timer to + make this connection's speed get checked again no later than when + this time is up */ + Curl_expire(data, data->set.low_speed_time*1000); } return CURLE_OK; } -- cgit v1.2.1 From 9f44a95522162c0f4a61093efe1bf1f58b087358 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Thu, 30 Aug 2007 20:34:57 +0000 Subject: Renamed several libcurl error codes and options to make them more general and allow reuse by multiple protocols. Several unused error codes were removed. In all cases, macros were added to preserve source (and binary) compatibility with the old names. These macros are subject to removal at a future date, but probably not before 2009. An application can be tested to see if it is using any obsolete code by compiling it with the CURL_NO_OLDIES macro defined. Documented some newer error codes in libcurl-error(3) --- lib/speedcheck.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/speedcheck.c') diff --git a/lib/speedcheck.c b/lib/speedcheck.c index adda8a963..aa57ccd59 100644 --- a/lib/speedcheck.c +++ b/lib/speedcheck.c @@ -57,7 +57,7 @@ CURLcode Curl_speedcheck(struct SessionHandle *data, "Less than %d bytes/sec transfered the last %d seconds", data->set.low_speed_limit, data->set.low_speed_time); - return CURLE_OPERATION_TIMEOUTED; + return CURLE_OPERATION_TIMEDOUT; } Curl_expire(data, howlong); } -- cgit v1.2.1 From d65cf7889b4ce669876f9e05442fd09f6fe40e37 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 28 Jan 2010 15:34:18 +0000 Subject: fix printf-style format strings --- lib/speedcheck.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/speedcheck.c') diff --git a/lib/speedcheck.c b/lib/speedcheck.c index aa57ccd59..9f801e1fc 100644 --- a/lib/speedcheck.c +++ b/lib/speedcheck.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2006, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2010, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -54,7 +54,7 @@ CURLcode Curl_speedcheck(struct SessionHandle *data, /* we have been this slow for long enough, now die */ failf(data, "Operation too slow. " - "Less than %d bytes/sec transfered the last %d seconds", + "Less than %ld bytes/sec transfered the last %ld seconds", data->set.low_speed_limit, data->set.low_speed_time); return CURLE_OPERATION_TIMEDOUT; -- cgit v1.2.1 From 2309b4e330b96bc2e1f8e36b6184015e59544037 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 24 Mar 2010 11:02:54 +0100 Subject: remove the CVSish $Id$ lines --- lib/speedcheck.c | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/speedcheck.c') diff --git a/lib/speedcheck.c b/lib/speedcheck.c index 9f801e1fc..38bad5a57 100644 --- a/lib/speedcheck.c +++ b/lib/speedcheck.c @@ -18,7 +18,6 @@ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * KIND, either express or implied. * - * $Id$ ***************************************************************************/ #include "setup.h" -- cgit v1.2.1 From 1702a2c08d3a0ed5945f34e6cd38436611f65164 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Tue, 19 Apr 2011 15:54:13 +0200 Subject: Fix a couple of spelling errors in lib/ Found with codespell. --- lib/speedcheck.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/speedcheck.c') diff --git a/lib/speedcheck.c b/lib/speedcheck.c index 38bad5a57..a43acb3f0 100644 --- a/lib/speedcheck.c +++ b/lib/speedcheck.c @@ -53,7 +53,7 @@ CURLcode Curl_speedcheck(struct SessionHandle *data, /* we have been this slow for long enough, now die */ failf(data, "Operation too slow. " - "Less than %ld bytes/sec transfered the last %ld seconds", + "Less than %ld bytes/sec transferred the last %ld seconds", data->set.low_speed_limit, data->set.low_speed_time); return CURLE_OPERATION_TIMEDOUT; -- cgit v1.2.1 From 889d1e973fb718a77c5000141d724ce03863af23 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 22 Apr 2011 23:01:30 +0200 Subject: whitespace cleanup: no space first in conditionals "if(a)" is our style, not "if( a )" --- lib/speedcheck.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/speedcheck.c') diff --git a/lib/speedcheck.c b/lib/speedcheck.c index a43acb3f0..56ac34aef 100644 --- a/lib/speedcheck.c +++ b/lib/speedcheck.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2010, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -49,7 +49,7 @@ CURLcode Curl_speedcheck(struct SessionHandle *data, for "low speed time" seconds we consider that enough reason to abort the download. */ - if( (howlong/1000) > data->set.low_speed_time) { + if((howlong/1000) > data->set.low_speed_time) { /* we have been this slow for long enough, now die */ failf(data, "Operation too slow. " -- cgit v1.2.1 From f1586cb4775681810afd8e6626e7842d459f3b85 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 26 Jul 2011 17:23:27 +0200 Subject: stdio.h, stdlib.h, string.h, stdarg.h and ctype.h inclusion done in setup_once.h --- lib/speedcheck.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'lib/speedcheck.c') diff --git a/lib/speedcheck.c b/lib/speedcheck.c index 56ac34aef..13d5d233e 100644 --- a/lib/speedcheck.c +++ b/lib/speedcheck.c @@ -22,9 +22,6 @@ #include "setup.h" -#include -#include - #include #include "urldata.h" #include "sendf.h" -- cgit v1.2.1 From 81ead2c4e75a686729586ffb07d79e2efe2a60ba Mon Sep 17 00:00:00 2001 From: Adriano Meirelles Date: Thu, 8 Sep 2011 08:38:59 +0200 Subject: Curl_speedcheck: don't mistakenly clear Curl_expire() The current version of speedcheck.c may disable timeout by setting zero to Curl_expire. Which is fine using the curl_multi_perform, because it recheck all timeout internals, but when using custom event poller (like hiperfifo.c) it may keep stalle connection forever. --- lib/speedcheck.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lib/speedcheck.c') diff --git a/lib/speedcheck.c b/lib/speedcheck.c index 13d5d233e..ca2323f57 100644 --- a/lib/speedcheck.c +++ b/lib/speedcheck.c @@ -41,12 +41,12 @@ CURLcode Curl_speedcheck(struct SessionHandle *data, (Curl_tvlong(data->state.keeps_speed) != 0) && (data->progress.current_speed < data->set.low_speed_limit)) { long howlong = Curl_tvdiff(now, data->state.keeps_speed); + long nextcheck = (data->set.low_speed_time * 1000) - howlong; /* We are now below the "low speed limit". If we are below it for "low speed time" seconds we consider that enough reason to abort the download. */ - - if((howlong/1000) > data->set.low_speed_time) { + if(nextcheck <= 0) { /* we have been this slow for long enough, now die */ failf(data, "Operation too slow. " @@ -55,7 +55,10 @@ CURLcode Curl_speedcheck(struct SessionHandle *data, data->set.low_speed_time); return CURLE_OPERATION_TIMEDOUT; } - Curl_expire(data, howlong); + else { + /* wait complete low_speed_time */ + Curl_expire(data, nextcheck); + } } else { /* we keep up the required speed all right */ -- cgit v1.2.1