diff options
author | Kostyantyn Ovechko <fastinetserver@gmail.com> | 2010-06-22 03:31:52 +0300 |
---|---|---|
committer | Kostyantyn Ovechko <fastinetserver@gmail.com> | 2010-06-22 03:31:52 +0300 |
commit | 127d27e4e285b75dccc1ef4ea6723498d4d37b92 (patch) | |
tree | eac72693165cf6b1fa31bbf2484e04ded2326397 | |
parent | Add options [connections].connection_timeout, [connections].ftp_response_time... (diff) | |
download | idfetch-127d27e4e285b75dccc1ef4ea6723498d4d37b92.tar.gz idfetch-127d27e4e285b75dccc1ef4ea6723498d4d37b92.tar.bz2 idfetch-127d27e4e285b75dccc1ef4ea6723498d4d37b92.zip |
Add [connections].low_connection_speed_limit, [connections].low_connection_speed_time
LOW_CONNECTION_SPEED_LIMIT
Define the low speed limit for connection. Pass a long as parameter. It
contains the transfer speed in bytes per second that the transfer should be
below during LOW_CONNECTION_SPEED_TIME seconds to consider it too slow and abort.
default:
low_connection_speed_limit=1000
LOW_CONNECTION_SPEED_TIME
Pass a long as parameter. It contains the time in seconds that the transfer
should be below the LOW_SPEED_LIMIT to consider it too slow and abort.
default:
low_connection_speed_time=10
-rw-r--r-- | segget/segget.conf | 120 | ||||
-rw-r--r-- | segget/segget.cpp | 2 | ||||
-rw-r--r-- | segget/segment.cpp | 3 | ||||
-rw-r--r-- | segget/settings.cpp | 56 |
4 files changed, 112 insertions, 69 deletions
diff --git a/segget/segget.conf b/segget/segget.conf index a8fcea1..240630c 100644 --- a/segget/segget.conf +++ b/segget/segget.conf @@ -6,62 +6,82 @@ segments_dir=./tmp fetch-only=0 [distfiles] -#Each distfile can have only up to max_connection_num_per_distfile simultaneous +# Each distfile can have only up to max_connection_num_per_distfile simultaneous # connections. # default: # max_connection_num_per_distfile=3 max_connection_num_per_distfile=3 [segments] -#define maximum segment size in bytes -#default: -#max_segment_size=500000 +# define maximum segment size in bytes +# default: +# max_segment_size=500000 max_segment_size=500000 resume_on=1 # in case segment download was unsuccessful, new attempts are made. When attempts -#number reaches max_tries, segment gets FAILED status and error logged to error_log -#default: +# number reaches max_tries, segment gets FAILED status and error logged to error_log +# default: #max_tries=30 max_tries=30 [connections] -#define maximum number of connections +# define maximum number of connections max_connections=10 -max_total_speed=50000 -max_connection_speed=20000 -#Define minimum speed for connection. If avg speed is less then defined by min_connection_speed during -#min_speed_period connection will be dropped and reestablished. -min_connection_speed=1000 -#Define interval in seconds to measure min_avg_speed -min_speed_interval=5 - -#Set the number of seconds to wait while trying to connect. Use 0 to wait -#indefinitely. Pass a long. It should contain the maximum time in seconds that -#you allow the connection to the server to take. This only limits the connection -#phase, once it has connected, this option is of no more use. Set to zero to -#disable connection timeout (it will then only timeout on the system's internal -#timeouts). See also the TIMEOUT option. -#default: -#connection_timeout=15 + +# Set the number of seconds to wait while trying to connect. Use 0 to wait +# indefinitely. Pass a long. It should contain the maximum time in seconds that +# you allow the connection to the server to take. This only limits the connection +# phase, once it has connected, this option is of no more use. Set to zero to +# disable connection timeout (it will then only timeout on the system's internal +# timeouts). See also the TIMEOUT option. +# default: +# connection_timeout=15 connection_timeout=15 -#Set a timeout period (in seconds) on the amount of time that the server is -#allowed to take in order to generate a response message for a command before the -#session is considered hung. While awaiting for a response, this value overrides -#TIMEOUT. It is recommended that if used in conjunction with TIMEOUT, you set -#FTP_RESPONSE_TIMEOUT to a value smaller than TIMEOUT. -#default: -#ftp_response_timeout=5000 + +# Set a timeout period (in seconds) on the amount of time that the server is +# allowed to take in order to generate a response message for a command before the +# session is considered hung. While awaiting for a response, this value overrides +# TIMEOUT. It is recommended that if used in conjunction with TIMEOUT, you set +# FTP_RESPONSE_TIMEOUT to a value smaller than TIMEOUT. +# default: +# ftp_response_timeout=5000 ftp_response_timeout=5000 -#maximum amount of time to download segment in seconds -#Set the maximum number of seconds for a connection to execute. -#Pass a long as parameter containing the maximum time in seconds that you allow -#the transfer operation to take. Normally, name lookups can take a considerable -#time and limiting operations to less than a few minutes risk aborting perfectly -#normal operations. -#default: -#timeout=6000 + +# maximum amount of time to download segment in seconds +# Set the maximum number of seconds for a connection to execute. +# Pass a long as parameter containing the maximum time in seconds that you allow +# the transfer operation to take. Normally, name lookups can take a considerable +# time and limiting operations to less than a few minutes risk aborting perfectly +# normal operations. +# default: +# timeout=6000 timeout=6000 +# LOW_CONNECTION_SPEED_LIMIT +# Define the low speed limit for connection. Pass a long as parameter. It +# contains the transfer speed in bytes per second that the transfer should be +# below during LOW_CONNECTION_SPEED_TIME seconds to consider it too slow and abort. +# default: +# low_connection_speed_limit=1000 +low_connection_speed_limit=1000 + +# LOW_CONNECTION_SPEED_TIME +# Pass a long as parameter. It contains the time in seconds that the transfer +# should be below the LOW_CONNECTION_SPEED_LIMIT to consider it too slow and abort. +# default: +# low_connection_speed_time=10 +low_connection_speed_time=10 + +# MAX_CONNECTION_SPEED +# If a download exceeds this speed (counted in bytes per second) on cumulative +# average during the transfer, the transfer will pause to keep the average rate +# less than or equal to the parameter value. Defaults to unlimited speed. +# default: +# max_connection_speed=0 +max_connection_speed=0 + +#max_total_speed=50000 + [mirrors] max_connections_num_per_mirror=2 benchmarking_on=1 @@ -76,7 +96,7 @@ allow_ftp=1 [schedule] [interfaces] -#bind_if=192.168.56.2 +# bind_if=192.168.56.2 [user-data] user_agent=segget @@ -85,34 +105,34 @@ ftp-user=anonymous ftp-password=me@mail.ru [proxy] -#Specify a proxy to use (address and port). +# Specify a proxy to use (address and port). proxy-ip=none proxy-port=none Specify the user and password for authentication on a proxy server. proxy-user=user proxy-password=password -#Set to forbid using proxies. +# Set to forbid using proxies. no-proxy=1 [proxy-fetcher] -#Specify proxy-fetcher address and port +# Specify proxy-fetcher address and port proxy-fetcher-ip=none proxy-fetcher-port=none -#Specify the user and password for authentication on a proxy-fetcher-server. -#proxy-fetcher-user=user -#proxy-fetcher-password=password +# Specify the user and password for authentication on a proxy-fetcher-server. +# proxy-fetcher-user=user +# proxy-fetcher-password=password -#Set to forbid direct connections to Internet servers if it's possible to use -#proxy-fetcher. +# Set to forbid direct connections to Internet servers if it's possible to use +# proxy-fetcher. use-proxy-fetcher-demon-if-possible=1 -#Set to forbid direct connections to Internet servers. +# Set to forbid direct connections to Internet servers. use-proxy-fetcher-demon-only=0 # Set to forbid using proxy-fetcher. no-proxy-fetcher [mirroring] -#Set directory prefix to prefix. The directory prefix is the directory where all -#other files and subdirectories will be saved for mirroring. +# Set directory prefix to prefix. The directory prefix is the directory where all +# other files and subdirectories will be saved for mirroring. directory-prefix=./mirror [logs] diff --git a/segget/segget.cpp b/segget/segget.cpp index c082773..2ea2045 100644 --- a/segget/segget.cpp +++ b/segget/segget.cpp @@ -142,7 +142,7 @@ int download_pkgs(){ Tsegment *current_segment; CURL *e = msg->easy_handle; curl_easy_getinfo(msg->easy_handle, CURLINFO_PRIVATE, ¤t_segment); - string result_msg_text="RESULT:"+toString(msg->data.result)+" "+curl_easy_strerror(msg->data.result)+"while downloading segment"; + string result_msg_text="RESULT:"+toString(msg->data.result)+" "+curl_easy_strerror(msg->data.result)+" while downloading segment"; msg_status1(current_segment->connection_num,current_segment->segment_num,result_msg_text); curl_multi_remove_handle(cm, e); fclose(current_segment->segment_file); diff --git a/segget/segment.cpp b/segget/segment.cpp index fb043cb..34ee3c2 100644 --- a/segget/segment.cpp +++ b/segget/segment.cpp @@ -123,6 +123,9 @@ int Tsegment::add_easy_handle_to_multi(CURLM *cm){ curl_easy_setopt(easyhandle, CURLOPT_RANGE, range.c_str()); curl_easy_setopt(easyhandle, CURLOPT_TIMEOUT, settings.time_out); curl_easy_setopt(easyhandle, CURLOPT_FTP_RESPONSE_TIMEOUT, settings.ftp_response_timeout); + curl_easy_setopt(easyhandle, CURLOPT_LOW_SPEED_LIMIT, settings.low_connection_speed_limit); + curl_easy_setopt(easyhandle, CURLOPT_LOW_SPEED_TIME, settings.low_connection_speed_time); + curl_easy_setopt(easyhandle, CURLOPT_MAX_RECV_SPEED_LARGE, settings.max_connection_speed); //set connection timeout curl_easy_setopt(easyhandle, CURLOPT_CONNECTTIMEOUT, settings.connection_timeout); curl_easy_setopt(easyhandle, CURLOPT_WRITEFUNCTION, write_data); diff --git a/segget/settings.cpp b/segget/settings.cpp index ee58e2a..451168d 100644 --- a/segget/settings.cpp +++ b/segget/settings.cpp @@ -9,27 +9,42 @@ using namespace std; class Tsettings{ private: - bool resume_on; public: + //folders string distfiles_dir; string segments_dir; - uint connection_timeout; - uint ftp_response_timeout; - uint time_out; - uint max_connections; + //distfiles uint max_connection_num_per_distfile; + //segments uint max_segment_size; + bool resume_on; uint max_tries; + //connections + uint max_connections; + uint connection_timeout; + uint ftp_response_timeout; + uint time_out; + uint low_connection_speed_limit; + uint low_connection_speed_time; + uint max_connection_speed; Tsettings(): - resume_on(1), + //folders distfiles_dir("./distfiles"), segments_dir("./tmp"), - connection_timeout(15), - ftp_response_timeout(5000),time_out(6000), - max_connections(6), + //distfiles max_connection_num_per_distfile(3), + //segments max_segment_size(500000), - max_tries(30) + resume_on(1), + max_tries(30), + //connections + max_connections(6), + connection_timeout(15), + ftp_response_timeout(5000), + time_out(6000), + low_connection_speed_limit(1000), + low_connection_speed_time(10), + max_connection_speed(0) {}; void set_resume(bool resume_setting){resume_on=resume_setting;}; bool get_resume(){return resume_on;}; @@ -42,14 +57,19 @@ void Tsettings::load_from_conf_file(){ conf.set(segments_dir, "folders", "segments_dir"); // log("segments_dir set to:"+segments_dir); - conf.set(max_connections, "connections", "max_connections"); - conf.set(connection_timeout, "connections", "connection_timeout"); - conf.set(ftp_response_timeout, "connections", "ftp_response_timeout"); - conf.set(time_out, "connections", "timeout"); - conf.set(max_connection_num_per_distfile, "distfiles", "max_connection_num_per_distfile"); - conf.set(resume_on, "segments", "resume_on"); - conf.set(max_segment_size, "segments", "max_segment_size"); - conf.set(max_tries, "segments", "max_tries"); + conf.set(max_connection_num_per_distfile, "distfiles", "max_connection_num_per_distfile"); + + conf.set(resume_on, "segments", "resume_on"); + conf.set(max_segment_size, "segments", "max_segment_size"); + conf.set(max_tries, "segments", "max_tries"); + + conf.set(max_connections, "connections", "max_connections"); + conf.set(connection_timeout, "connections", "connection_timeout"); + conf.set(ftp_response_timeout, "connections", "ftp_response_timeout"); + conf.set(time_out, "connections", "timeout"); + conf.set(low_connection_speed_limit, "connections", "low_connection_speed_limit"); + conf.set(low_connection_speed_time, "connections", "low_connection_speed_time"); + conf.set(max_connection_speed, "connections", "max_connection_speed"); } Tsettings settings; |