1 /*****************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * The contents of this file are subject to the Mozilla Public License
9 * Version 1.0 (the "License"); you may not use this file except in
10 * compliance with the License. You may obtain a copy of the License at
11 * http://www.mozilla.org/MPL/
13 * Software distributed under the License is distributed on an "AS IS"
14 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
15 * License for the specific language governing rights and limitations
18 * The Original Code is Curl.
20 * The Initial Developer of the Original Code is Daniel Stenberg.
22 * Portions created by the Initial Developer are Copyright (C) 1998.
23 * All Rights Reserved.
25 * ------------------------------------------------------------
27 * - Daniel Stenberg <daniel@haxx.se>
38 * ------------------------------------------------------------
39 ****************************************************************************/
44 #if defined(__MINGW32__)
48 #include <curl/curl.h>
51 #include "speedcheck.h"
53 void speedinit(struct UrlData *data)
55 memset(&data->keeps_speed, 0, sizeof(struct timeval));
58 CURLcode speedcheck(struct UrlData *data,
61 if((data->progress.current_speed >= 0) &&
62 data->low_speed_time &&
63 (tvlong(data->keeps_speed) != 0) &&
64 (data->progress.current_speed < data->low_speed_limit)) {
66 /* We are now below the "low speed limit". If we are below it
67 for "low speed time" seconds we consider that enough reason
68 to abort the download. */
70 if( tvdiff(now, data->keeps_speed) > data->low_speed_time) {
71 /* we have been this slow for long enough, now die */
73 "Operation too slow. "
74 "Less than %d bytes/sec transfered the last %d seconds",
75 data->low_speed_limit,
76 data->low_speed_time);
77 return CURLE_OPERATION_TIMEOUTED;
81 /* we keep up the required speed all right */
82 data->keeps_speed = now;