diff options
author | Kostyantyn Ovechko <fastinetserver@gmail.com> | 2010-08-04 23:24:24 +0300 |
---|---|---|
committer | Kostyantyn Ovechko <fastinetserver@gmail.com> | 2010-08-04 23:24:24 +0300 |
commit | 0f4e84241ea7ebbc035658b4b7daa3ecf160c1e0 (patch) | |
tree | 335d5da2786cd79a94bc6d6678b549390d62703f | |
parent | Add DSCRIPTREJECTED status for distfiles. (diff) | |
download | idfetch-0f4e84241ea7ebbc035658b4b7daa3ecf160c1e0.tar.gz idfetch-0f4e84241ea7ebbc035658b4b7daa3ecf160c1e0.tar.bz2 idfetch-0f4e84241ea7ebbc035658b4b7daa3ecf160c1e0.zip |
Add check if only local networks and proxy_fetcher networks are used and if all their mirrors failed consider fetching to be failded.
In such case distfile should be considered failed, since no other options left.
-rw-r--r-- | segget/connection.cpp | 16 | ||||
-rw-r--r-- | segget/distfile.cpp | 30 | ||||
-rw-r--r-- | segget/distfile.h | 1 | ||||
-rw-r--r-- | segget/response.h | 1 | ||||
-rw-r--r-- | segget/settings.cpp | 5 | ||||
-rw-r--r-- | segget/settings.h | 4 | ||||
-rw-r--r-- | segget/ui_server.cpp | 18 | ||||
-rw-r--r-- | tuiclient/distfilewindow.cpp | 1 | ||||
-rw-r--r-- | tuiclient/mainwindow.cpp | 9 | ||||
-rw-r--r-- | tuiclient/tuiclient.cpp | 8 | ||||
-rw-r--r-- | tuiclient/tuidistfile.cpp | 1 | ||||
-rw-r--r-- | tuiclient/tuidistfile.h | 1 |
12 files changed, 68 insertions, 27 deletions
diff --git a/segget/connection.cpp b/segget/connection.cpp index 25e3d79..af9b85e 100644 --- a/segget/connection.cpp +++ b/segget/connection.cpp @@ -203,14 +203,16 @@ void Tconnection::stop(CURLcode connection_result){ // already done earlier in this function Pcurr_mirror=find_mirror(strip_mirror_name(segment->url)); segment->status=SDOWNLOADED; segment->parent_distfile->inc_dld_segments_count(segment); - if ((segment->parent_distfile->get_status()!=DFAILED) and (segment->parent_distfile->get_status()!=DDOWNLOADED)){ - if (segment->parent_distfile->active_connections_num>0){ - segment->parent_distfile->set_status(DDOWNLOADING); - }else{ - segment->parent_distfile->set_status(DWAITING); - } - } }; + if ((segment->parent_distfile->get_status()!=DFAILED) + and (segment->parent_distfile->get_status()!=DDOWNLOADED) + and (segment->parent_distfile->get_status()!=DALL_LM_AND_PF_MIRRORS_FAILED)){ + if (segment->parent_distfile->active_connections_num>0){ + segment->parent_distfile->set_status(DDOWNLOADING); + }else{ + segment->parent_distfile->set_status(DWAITING); + } + } }catch(...){ error_log("Error in connection.cpp: stop()"); } diff --git a/segget/distfile.cpp b/segget/distfile.cpp index 21d90c8..e8f4916 100644 --- a/segget/distfile.cpp +++ b/segget/distfile.cpp @@ -143,6 +143,10 @@ bool Tdistfile::allows_new_actions(){ debug("No new connection for distfile:"+name+". Distfile has DFAILED status"); return false; } + if (status==DALL_LM_AND_PF_MIRRORS_FAILED){ + debug("No new connection for distfile:"+name+". Distfile has DALL_LM_AND_PF_MIRRORS_FAILED status"); + return false; + } // debug("Distfile "+Ppkg_array[pkg_num]->distfile_vector[distfile_num]->name+" allows new connections"); // debug(" distfile_num:"+toString(distfile_num)); if (active_connections_num<settings.max_connection_num_per_distfile){ @@ -495,6 +499,32 @@ uint Tdistfile::provide_local_network(CURLM* cm, uint connection_num, uint seg_n debug(" So best LOCAL network is network#:"+toString(best_local_network_num)); return choose_best_local_mirror(cm, connection_num, best_local_network_num, seg_num); }else{ + debug(" Haven't found best local network"); + // if only local and pf networs present, some distfiles may fail all local mirrors => check + if (settings.only_local_and_proxy_fetcher_mode_networks_flag){ + debug(" Checking if all possible mirrors have failed"); + bool all_neworks_are_local_with_failed_mirrors=true; + for (uint network_num=0; network_num<MAX_NETWORKS; network_num++){ + if (network_array[network_num].priority>0){ + debug("checking network:"+toString(network_num)); + if (network_array[network_num].network_mode==MODE_LOCAL){ + if (network_distfile_brokers_array[network_num].phase!=E_ALL_LOCAL_MIRRORS_FAILED){ + all_neworks_are_local_with_failed_mirrors=false; + break; + } + }else{ // mode=MODE_PROXY_FETCHER (because only these 2 modes were defined in settings + if (network_distfile_brokers_array[network_num].phase!=E_ALL_PROXY_FETCHER_MIRRORS_FAILED){ + all_neworks_are_local_with_failed_mirrors=false; + break; + } + } + } + } + if (all_neworks_are_local_with_failed_mirrors){ + set_status(DALL_LM_AND_PF_MIRRORS_FAILED); + return R_LM_PF_ALL_MIRRORS_FAILED; + } + } if (allow_proxy_fetcher_mirrors){ return ALLOW_REQUESTS_TO_PROXY_FETCHERS; }else{ diff --git a/segget/distfile.h b/segget/distfile.h index 56e2b79..e2e8afd 100644 --- a/segget/distfile.h +++ b/segget/distfile.h @@ -80,6 +80,7 @@ enum Tdistfile_status{ DPROXY_DOWNLOADING, DPROXY_DOWNLOADED, DPROXY_FAILED, + DALL_LM_AND_PF_MIRRORS_FAILED, DWAITING, DSCRIPTREJECTED, DDOWNLOADING, diff --git a/segget/response.h b/segget/response.h index 571f17b..d78bc7c 100644 --- a/segget/response.h +++ b/segget/response.h @@ -48,6 +48,7 @@ using namespace std; #define R_R_DOWNLOADING 109 #define R_LM_PF_R_NO_FREE_NETWORK_CONNECTION_FOUND 110 +#define R_LM_PF_ALL_MIRRORS_FAILED 111 #define ALLOW_REQUESTS_TO_PROXY_FETCHERS 201 #define DO_NOT_ALLOW_REQUESTS_TO_PROXY_FETCHERS 202 diff --git a/segget/settings.cpp b/segget/settings.cpp index 8a4a324..5789a03 100644 --- a/segget/settings.cpp +++ b/segget/settings.cpp @@ -118,9 +118,12 @@ void Tsettings::init(){ conf.set("networks","network"+toString(network_num)+"_priority",cur_network_priority,0,10); if (cur_network_priority>0){ network_array[network_num].init(cur_network_priority); + if ((network_array[network_num].network_mode==MODE_REMOTE) + or (network_array[network_num].network_mode==MODE_CORAL_CDN)){ + only_local_and_proxy_fetcher_mode_networks_flag=false; + } } } - conf.set("ui_server","ui_ip",ui_ip); conf.set("ui_server","ui_port",ui_port,1,65535); diff --git a/segget/settings.h b/segget/settings.h index 38fb115..4f36850 100644 --- a/segget/settings.h +++ b/segget/settings.h @@ -73,6 +73,8 @@ class Tsettings{ //provide_proxy_fether_to_others string provide_proxy_fetcher_ip; ulong provide_proxy_fetcher_port; + //networks + bool only_local_and_proxy_fetcher_mode_networks_flag; //ui_server string ui_ip; ulong ui_port; @@ -126,6 +128,8 @@ class Tsettings{ //provide_proxy_fether_to_others provide_proxy_fetcher_ip("127.0.0.1"), provide_proxy_fetcher_port(9888), + //networks + only_local_and_proxy_fetcher_mode_networks_flag(true), //ui_server ui_ip("127.0.0.1"), ui_port(9999), diff --git a/segget/ui_server.cpp b/segget/ui_server.cpp index 8fb48e6..09cb26d 100644 --- a/segget/ui_server.cpp +++ b/segget/ui_server.cpp @@ -169,14 +169,14 @@ void *run_ui_server(void * ){ close(fd); debug("Client parted from fd:"+toString(fd)); }else{ - error_log("reading buffer"); + debug("reading buffer"); char buffer[1000]=""; if (nread!=read(fd, &buffer, nread)){ debug("Not all data has been read from ui_client()"); } string request_str_before,request_str_after; - error_log("received_from tuiclient:"); - error_log(buffer); + debug("received_from tuiclient:"); + debug(buffer); split("<d>",buffer,request_str_before,request_str_after); split("<.>",request_str_after,request_str_before,request_str_after); string distfile_by_name_lookup_request=request_str_before; @@ -217,24 +217,20 @@ void *run_ui_server(void * ){ ui_server.send_to_fd(fd, "<m>N<t><.>"); //distfile is not in the list quit break; case IN_QUEUE: - string err_msg="Found distfile by name:"; - err_msg=err_msg+buffer; - error_log_no_msg(err_msg); ui_server.send_to_fd(fd, "<m>y<t><.>"); //distfile is in the list continue // Get this info to catch up! for (uint line_num=0; line_num<=max_published_screenline_num;line_num++){ ui_server.send_connection_msg_to_fd(fd, line_num, screenlines[line_num]); - error_log_no_msg("Sending to client line:"+toString(line_num)+" "+screenlines[line_num]); - debug_no_msg("Sending to client line:"+toString(line_num)+" "+screenlines[line_num]); + debug("Sending to client line:"+toString(line_num)+" "+screenlines[line_num]); } - error_log_no_msg("Sending to client distfiles_num:"+toString(request_server_pkg.Pdistfile_list.size())); + debug("Sending to client distfiles_num:"+toString(request_server_pkg.Pdistfile_list.size())); for (ulong distfile_num=0; distfile_num<request_server_pkg.Pdistfile_list.size(); distfile_num++){ ui_server.send_distfile_progress_msg_to_fd(fd, request_server_pkg.Pdistfile_list[distfile_num]->get_distfile_progress_str()); - error_log_no_msg("Sending to client:"+request_server_pkg.Pdistfile_list[distfile_num]->get_distfile_progress_str()); + debug("Sending to client:"+request_server_pkg.Pdistfile_list[distfile_num]->get_distfile_progress_str()); } for (ulong distfile_num=0; distfile_num<proxy_fetcher_pkg.Pdistfile_list.size(); distfile_num++){ ui_server.send_distfile_progress_msg_to_fd(fd, proxy_fetcher_pkg.Pdistfile_list[distfile_num]->get_distfile_progress_str()); - error_log_no_msg("Sending to client:"+proxy_fetcher_pkg.Pdistfile_list[distfile_num]->get_distfile_progress_str()); + debug("Sending to client:"+proxy_fetcher_pkg.Pdistfile_list[distfile_num]->get_distfile_progress_str()); } } } diff --git a/tuiclient/distfilewindow.cpp b/tuiclient/distfilewindow.cpp index 58ed688..43a2009 100644 --- a/tuiclient/distfilewindow.cpp +++ b/tuiclient/distfilewindow.cpp @@ -72,6 +72,7 @@ void Tdistfile_window::compose(){ color_distfile_downloaded(window); break; case DFAILED: + case DALL_LM_AND_PF_MIRRORS_FAILED: color_distfile_failed(window); break; case DNEW: diff --git a/tuiclient/mainwindow.cpp b/tuiclient/mainwindow.cpp index 1dbd590..81fc7e9 100644 --- a/tuiclient/mainwindow.cpp +++ b/tuiclient/mainwindow.cpp @@ -151,17 +151,18 @@ void Tmainwindow::init(){ //don't wait for enter cbreak(); //enable arrow keys - keypad(stdscr,TRUE); - keypad(window,TRUE); + keypad(stdscr,true); + keypad(window,true); // exit_flag=FALSE; - visible=TRUE; - notfresh=TRUE; + visible=true; + notfresh=true; // wclear(window); // wrefresh(window); // refresh(); help_win.init(" HELP ",14,31,5,5); log_win.init(" LOG ",12,50,5,5); distfiles_win.init(" DISTFILES ",12,50,5,5); + distfiles_win.visible=true; error_log_win.init(" ERROR LOG ",12,50,5,5); disconnected(); show(); diff --git a/tuiclient/tuiclient.cpp b/tuiclient/tuiclient.cpp index 00561a4..5035115 100644 --- a/tuiclient/tuiclient.cpp +++ b/tuiclient/tuiclient.cpp @@ -120,13 +120,13 @@ void * watch_keyboard_thread_function(void *){ //tab - move between windows case (char)9:cur_window=next_window(); //KEY_DOWN - case (char)2:cur_window->down(1);mainwindow.set_line(25,toString((int)key));break; + case (char)2:cur_window->down(1);break; //KEY_RIGHT - case (char)5:cur_window->down(1);mainwindow.set_line(25,toString((int)key));break; + case (char)5:cur_window->down(1);break; //KEY_UP - case (char)3:cur_window->up(1);mainwindow.set_line(25,toString((int)key));break; + case (char)3:cur_window->up(1);break; //KEY_LEFT - case (char)4:cur_window->up(1);mainwindow.set_line(25,toString((int)key));break; + case (char)4:cur_window->up(1);break; //KEY_PG_DOWN case (char)82:cur_window->down(mainwindow.bottom_screenline_num);break; //KEY_PG_UP diff --git a/tuiclient/tuidistfile.cpp b/tuiclient/tuidistfile.cpp index 15138d3..a6b31a3 100644 --- a/tuiclient/tuidistfile.cpp +++ b/tuiclient/tuidistfile.cpp @@ -37,6 +37,7 @@ string Ttuidistfile::statusToString(){ case DPROXY_DOWNLOADING: return "Downloading via proxy"; case DPROXY_DOWNLOADED: return "Downloaded via proxy"; case DPROXY_FAILED: return "Failed"; + case DALL_LM_AND_PF_MIRRORS_FAILED: return "All mirrors failed"; case DWAITING: return "Waiting"; case DSCRIPTREJECTED: return "Rejected by script"; case DDOWNLOADING: return "Downloading"; diff --git a/tuiclient/tuidistfile.h b/tuiclient/tuidistfile.h index 866f049..f24815c 100644 --- a/tuiclient/tuidistfile.h +++ b/tuiclient/tuidistfile.h @@ -39,6 +39,7 @@ enum Tdistfile_status{ DPROXY_DOWNLOADING, DPROXY_DOWNLOADED, DPROXY_FAILED, + DALL_LM_AND_PF_MIRRORS_FAILED, DWAITING, DSCRIPTREJECTED, DDOWNLOADING, |