diff options
author | 2010-07-20 03:50:43 +0300 | |
---|---|---|
committer | 2010-07-20 03:50:43 +0300 | |
commit | 4f917e4ccc9c14b453ad4db8b2b457c9c36c5683 (patch) | |
tree | 1fd1c39499717be84be75a6c75ed3f6c6c0cc5e6 | |
parent | Fix: segget freezes while trying to download files via proxy-fetcher (diff) | |
download | idfetch-4f917e4ccc9c14b453ad4db8b2b457c9c36c5683.tar.gz idfetch-4f917e4ccc9c14b453ad4db8b2b457c9c36c5683.tar.bz2 idfetch-4f917e4ccc9c14b453ad4db8b2b457c9c36c5683.zip |
Fix: error with connection counters
-rw-r--r-- | segget/connection.cpp | 32 | ||||
-rw-r--r-- | segget/distfile.cpp | 10 | ||||
-rw-r--r-- | segget/networkbroker.cpp | 4 |
3 files changed, 31 insertions, 15 deletions
diff --git a/segget/connection.cpp b/segget/connection.cpp index 108c991..c669f17 100644 --- a/segget/connection.cpp +++ b/segget/connection.cpp @@ -48,20 +48,28 @@ void Tconnection::start(CURLM *cm, uint network_number, uint distfile_num, Tsegm active=true; debug("Connecting network"+toString(network_num)); + segment->parent_distfile->active_connections_num++; + if (network_array[network_num].network_mode==MODE_PROXY_FETCHER){ connection_start_time_network_phase_for_pf_networks=segment->parent_distfile->network_distfile_brokers_array[network_num].phase; } + + Tmirror *Pcurr_mirror; string url; - if (network_array[network_num].network_mode!=MODE_REMOTE){ - url=network_array[network_num].benchmarked_mirror_list[mirror_num].url+segment->parent_distfile->name; - debug(" URL:"+url); - }else{ + if (network_array[network_num].network_mode==MODE_REMOTE){ url=segment->parent_distfile->url_list[mirror_num]; + Pcurr_mirror=find_mirror(strip_mirror_name(url)); + }else{ + Pcurr_mirror=&network_array[network_num].benchmarked_mirror_list[mirror_num]; + url=Pcurr_mirror->url+segment->parent_distfile->name; } + debug(" URL:"+url); - - network_array[network_num].benchmarked_mirror_list[best_mirror_num].start(); + debug("aaaaa"); + Pcurr_mirror->start(); + debug("bbbbb"); network_array[network_num].connect(); + debug("ccccc"); segment->prepare_for_connection(cm, connection_num, network_num, distfile_num, url); debug("Started connection for distfile: "+segment->parent_distfile->name); }catch(...){ @@ -87,8 +95,7 @@ void Tconnection::stop(int connection_result){ } } - Tdistfile* prnt_distfile=segment->parent_distfile; - prnt_distfile->active_connections_num--; + segment->parent_distfile->active_connections_num--; /* Tmirror *Pcurr_mirror; if (network_array[network_num].network_mode==MODE_LOCAL){ @@ -114,16 +121,16 @@ void Tconnection::stop(int connection_result){ switch (network_array[network_num].network_mode){ case MODE_LOCAL:{ // prnt_distfile->network_distfile_brokers_array[network_num].mirror_fails_vector[mirror_num]=true; - prnt_distfile->network_distfile_brokers_array[network_num].local_mirror_failed(mirror_num); + segment->parent_distfile->network_distfile_brokers_array[network_num].local_mirror_failed(mirror_num); // find_mirror(strip_mirror_name(segment->url)); break; } case MODE_PROXY_FETCHER:{ // prnt_distfile->network_distfile_brokers_array[network_num].mirror_fails_vector[mirror_num]=true; if (connection_start_time_network_phase_for_pf_networks==E_USE_AS_LOCAL_MIRRORS){ - prnt_distfile->network_distfile_brokers_array[network_num].local_mirror_failed(mirror_num); + segment->parent_distfile->network_distfile_brokers_array[network_num].local_mirror_failed(mirror_num); }else{ // proxy-fetcher mirror failed, if everything correct it must be in phase E_PROXY_FETCHER_DOWNLOADED, - prnt_distfile->network_distfile_brokers_array[network_num].proxy_fetcher_mirror_failed(mirror_num); + segment->parent_distfile->network_distfile_brokers_array[network_num].proxy_fetcher_mirror_failed(mirror_num); } // find_mirror(strip_mirror_name(segment->url)); break; @@ -137,6 +144,7 @@ void Tconnection::stop(int connection_result){ Pcurr_mirror->stop(time_left_from(connection_array[connection_num].start_time),0); if (segment->try_num>=settings.max_tries){ segment->status=SFAILED; +// segm error_log("Segment:"+segment->file_name+" has reached max_tries limit - segment.status set to FAILED"); } else segment->status=SWAITING; @@ -147,7 +155,7 @@ void Tconnection::stop(int connection_result){ // already done earlier in this function Pcurr_mirror=find_mirror(strip_mirror_name(segment->url)); Pcurr_mirror->stop(time_left_from(connection_array[connection_num].start_time),segment->segment_size); segment->status=SDOWNLOADED; - prnt_distfile->inc_dld_segments_count(segment); + segment->parent_distfile->inc_dld_segments_count(segment); }; }catch(...){ error_log("Error in connection.cpp: stop()"); diff --git a/segget/distfile.cpp b/segget/distfile.cpp index b27a52f..72dc158 100644 --- a/segget/distfile.cpp +++ b/segget/distfile.cpp @@ -258,7 +258,11 @@ bool Tdistfile::choose_best_mirror(CURLM* cm, uint connection_num, uint network_ for (url_num=0; url_num<url_count; url_num++){ Pcurr_mirror=find_mirror(strip_mirror_name(url_list[url_num])); + debug("Evaluating url:"+url_list[url_num] + +" active_connections:"+toString(Pcurr_mirror->get_active_num()) + +" connection limit:"+toString(settings.max_connections_num_per_mirror)); if (Pcurr_mirror->get_active_num()<settings.max_connections_num_per_mirror){ + debug("Url satisfies connection num per mirror limit"); curr_mirror_self_rating=Pcurr_mirror->mirror_on_the_wall(); if (curr_mirror_self_rating<best_mirror_self_rating){ best_mirror_num=url_num; @@ -272,8 +276,8 @@ bool Tdistfile::choose_best_mirror(CURLM* cm, uint connection_num, uint network_ } if (Pbest_mirror){ debug("Downloading from BEST_MIRROR:"+url_list[best_mirror_num]); - Pbest_mirror->start(); - active_connections_num++; +// Pbest_mirror->start(); +// active_connections_num++; connection_array[connection_num].start(cm, network_num, num, &dn_segments[seg_num], best_mirror_num); return R_R_DOWNLOAD_STARTED; } @@ -314,7 +318,7 @@ bool Tdistfile::choose_best_local_mirror(CURLM* cm, uint connection_num, uint ne - active_connections_num++; +// active_connections_num++; connection_array[connection_num].start(cm, network_num, num, &dn_segments[seg_num], best_mirror_num); return R_R_DOWNLOAD_STARTED; } diff --git a/segget/networkbroker.cpp b/segget/networkbroker.cpp index 760bcfe..c5e36d3 100644 --- a/segget/networkbroker.cpp +++ b/segget/networkbroker.cpp @@ -53,6 +53,10 @@ void Tnetwork_distfile_broker::local_mirror_failed(uint mirror_num){ if (failed_mirrors_num>=mirror_fails_vector.size()){ phase=E_ALL_LOCAL_MIRRORS_FAILED; failed_mirrors_num=0; + // clean the vector, to use it again when we switch to E_PROXY_FETCHER_DOWNLOADED phase + for (ulong mirr_num=0; mirr_num<mirror_fails_vector.size(); mirr_num++){ + mirror_fails_vector[mirr_num]=false; + } } } } |