summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKostyantyn Ovechko <fastinetserver@gmail.com>2010-08-16 00:02:01 +0300
committerKostyantyn Ovechko <fastinetserver@gmail.com>2010-08-16 00:02:01 +0300
commit6d003d27882dc6aae746264b0afde7e556bff0f3 (patch)
tree9d0d438f929f424e933beb628a2fc048de56f798
parentFix pkgconfig problem with libcrypto++, and rename segget.* to seggetd.* (diff)
downloadidfetch-6d003d27882dc6aae746264b0afde7e556bff0f3.tar.gz
idfetch-6d003d27882dc6aae746264b0afde7e556bff0f3.tar.bz2
idfetch-6d003d27882dc6aae746264b0afde7e556bff0f3.zip
Add show_help() function and remove deprecated code lines.
-rw-r--r--seggetd/connection.cpp36
-rw-r--r--seggetd/distfile.cpp184
-rw-r--r--seggetd/mirror.cpp3
-rw-r--r--seggetd/network0.conf6
-rw-r--r--seggetd/networkbroker.cpp65
-rw-r--r--seggetd/phase.cpp20
-rw-r--r--seggetd/pkg.cpp28
-rw-r--r--seggetd/proxyfetcher.cpp2
-rw-r--r--seggetd/requestserver.cpp2
-rw-r--r--seggetd/response.cpp3
-rw-r--r--seggetd/seggetd.conf6
-rw-r--r--seggetd/seggetd.cpp151
-rw-r--r--seggetd/segment.cpp22
-rw-r--r--seggetd/stats.cpp13
-rw-r--r--seggetd/str.cpp22
-rw-r--r--seggetd/tui.cpp9
-rw-r--r--seggetd/ui_server.cpp91
-rw-r--r--seggetd/utils.cpp54
18 files changed, 243 insertions, 474 deletions
diff --git a/seggetd/connection.cpp b/seggetd/connection.cpp
index 88f6069..721617c 100644
--- a/seggetd/connection.cpp
+++ b/seggetd/connection.cpp
@@ -32,9 +32,13 @@ uint Tconnection::total_connections=0;
Tconnection connection_array[MAX_CONNECTS];
void init_connections(){
- for (ulong connection_num=0; connection_num<MAX_CONNECTS; connection_num++){
- connection_array[connection_num].connection_num=connection_num;
- };
+ try{
+ for (ulong connection_num=0; connection_num<MAX_CONNECTS; connection_num++){
+ connection_array[connection_num].connection_num=connection_num;
+ };
+ }catch(...){
+ error_log("Error in connection.cpp: init_connections()");
+ }
}
int Tconnection::start(CURLM *cm, uint network_number, uint distfile_num, Tsegment *started_segment, uint best_mirror_num){
@@ -96,16 +100,7 @@ int Tconnection::start(CURLM *cm, uint network_number, uint distfile_num, Tsegme
}
return ERROR_WHILE_PREPARING_CONNECTION;
}
-/*
-string explain_curl_error(int error_code){
- try{
- //curl_easy_strerror(
- }catch(...){
- error_log("Error in connection.cpp: explain_curl_error()");
- }
- return "Error in connection.cpp: explain_curl_error()";
-}
-*/
+
void Tconnection::stop(CURLcode connection_result){
try{
stats.active_connections_counter--;
@@ -135,8 +130,8 @@ void Tconnection::stop(CURLcode connection_result){
if (! segment->segment_verification_is_ok()){
connection_result=CURLE_READ_ERROR;
Pcurr_mirror->stop(time_left_since(connection_array[connection_num].start_time),0);
- debug("curl_lies - there is a problem downloading segment");
- error_log("curl_lies - there is a problem downloading segment");
+ debug("libcurl stated succesful result but size for the segment is incorrect");
+ error_log("libcurl stated succesful result but size for the segment is incorrect");
}else{
Pcurr_mirror->stop(time_left_since(connection_array[connection_num].start_time),segment->segment_size);
}
@@ -147,16 +142,6 @@ void Tconnection::stop(CURLcode connection_result){
msg_clean_connection(connection_num);
-/*
- Tmirror *Pcurr_mirror;
- if (network_array[network_num].network_mode==MODE_LOCAL){
- Pcurr_mirror=&network_array[network_num].benchmarked_mirror_list[mirror_num];
- prnt_distfile->network_distfile_brokers_array[network_num].mirror_fails_vector[mirror_num]=true;
-// find_mirror(strip_mirror_name(segment->url));
- }else{
- Pcurr_mirror=find_mirror(strip_mirror_name(segment->url));
- }
-*/
debug("before gettimeofday");
timeval now_time;
gettimeofday(&now_time,NULL);
@@ -199,7 +184,6 @@ void Tconnection::stop(CURLcode connection_result){
// no error => count this one and start new
log("Succesfully downloaded "+segment->file_name+" on connection#"+toString(connection_num));
debug(" Successful download "+segment->url);
-// 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);
};
diff --git a/seggetd/distfile.cpp b/seggetd/distfile.cpp
index 883532a..e28528a 100644
--- a/seggetd/distfile.cpp
+++ b/seggetd/distfile.cpp
@@ -116,105 +116,101 @@ void Tdistfile::set_status(Tdistfile_status new_status){
}
int Tdistfile::request(ulong network_num, string msg){
- gettimeofday(&network_distfile_brokers_array[network_num].last_request_time, NULL);
- int sockfd;
- int len;
- struct sockaddr_in address;
- int result;
- //Create a socket for the client:
- sockfd = socket(AF_INET, SOCK_STREAM, 0);
-
- //Name the socket, as agreed with the server:
- address.sin_family = AF_INET;
- address.sin_addr.s_addr = inet_addr(network_array[network_num].proxy_fetcher_ip.c_str());
- address.sin_port = htons(network_array[network_num].proxy_fetcher_port);
- len = sizeof(address);
-
- //Connect your socket to the server’s socket:
- result = connect(sockfd, (struct sockaddr *)&address, len);
- if(result == -1) {
- error_log("Network:"+toString(network_num)+"Can't connect to proxy-fetcher");
- return R_PF_ERROR_ADDING_TO_PROXY_QUEUE;
- }
- if (msg.length()>90000){return R_PF_ERROR_ADDING_TO_PROXY_QUEUE;};
- char send_buffer[100000];
- // char recv_buffer[256];
- strcpy(send_buffer,msg.c_str());
- //You can now read and write via sockfd:
- if (write(sockfd, send_buffer, strlen(send_buffer))!=(int)msg.length()){
- error_log("Error in distfile.cpp: request(): Network:"+toString(network_num)+"request msg size and sent data size are different.");
- };
-
- fd_set readfds, testfds;
- FD_ZERO(&readfds);
- FD_SET(sockfd, &readfds);
- testfds = readfds;
-
- struct timeval response_timeout;
- response_timeout.tv_sec=1;
- response_timeout.tv_usec=0;
-
- result = select(FD_SETSIZE, &testfds, (fd_set *)0,
- (fd_set *)0, &response_timeout);
+ try{
+ gettimeofday(&network_distfile_brokers_array[network_num].last_request_time, NULL);
+ int sockfd;
+ int len;
+ struct sockaddr_in address;
+ int result;
+ //Create a socket for the client:
+ sockfd = socket(AF_INET, SOCK_STREAM, 0);
+
+ //Name the socket, as agreed with the server:
+ address.sin_family = AF_INET;
+ address.sin_addr.s_addr = inet_addr(network_array[network_num].proxy_fetcher_ip.c_str());
+ address.sin_port = htons(network_array[network_num].proxy_fetcher_port);
+ len = sizeof(address);
+
+ //Connect your socket to the server’s socket:
+ result = connect(sockfd, (struct sockaddr *)&address, len);
+ if(result == -1) {
+ error_log("Network:"+toString(network_num)+"Can't connect to proxy-fetcher");
+ return R_PF_ERROR_ADDING_TO_PROXY_QUEUE;
+ }
+ if (msg.length()>90000){return R_PF_ERROR_ADDING_TO_PROXY_QUEUE;};
+ char send_buffer[100000];
+ // char recv_buffer[256];
+ strcpy(send_buffer,msg.c_str());
+ //You can now read and write via sockfd:
+ if (write(sockfd, send_buffer, strlen(send_buffer))!=(int)msg.length()){
+ error_log("Error in distfile.cpp: request(): Network:"+toString(network_num)+"request msg size and sent data size are different.");
+ };
- if(FD_ISSET(sockfd,&testfds)) {
- int nread;
- ioctl(sockfd, FIONREAD, &nread);
+ fd_set readfds, testfds;
+ FD_ZERO(&readfds);
+ FD_SET(sockfd, &readfds);
+ testfds = readfds;
- char recv_buffer[1000];
- if(nread == 0) {
- close(sockfd);
- error_log("Error in distfile.cpp: request(): Network:"+toString(network_num)+" no response from proxy-fetcher");
+ struct timeval response_timeout;
+ response_timeout.tv_sec=1;
+ response_timeout.tv_usec=0;
+
+ result = select(FD_SETSIZE, &testfds, (fd_set *)0,
+ (fd_set *)0, &response_timeout);
+
+ if(FD_ISSET(sockfd,&testfds)) {
+ int nread;
+ ioctl(sockfd, FIONREAD, &nread);
+
+ char recv_buffer[1000];
+ if(nread == 0) {
+ close(sockfd);
+ error_log("Error in distfile.cpp: request(): Network:"+toString(network_num)+" no response from proxy-fetcher");
+ }else{
+ if (nread!=read(sockfd, recv_buffer, nread)){
+ error_log("Error in distfile.cpp: request(): Network:"+toString(network_num)+"response msg size and received data size are different.");
+ };
+ return decode_server_response(recv_buffer);
+ }
}else{
- if (nread!=read(sockfd, recv_buffer, nread)){
- error_log("Error in distfile.cpp: request(): Network:"+toString(network_num)+"response msg size and received data size are different.");
- };
- return decode_server_response(recv_buffer);
+ error_log("Error in distfile.cpp: request(): Network:"+toString(network_num)+" zero size response from proxy-fetcher");
}
- }else{
- error_log("Error in distfile.cpp: request(): Network:"+toString(network_num)+" zero size response from proxy-fetcher");
+ close(sockfd);
+ return R_PF_ERROR_ADDING_TO_PROXY_QUEUE;
+ }catch(...){
+ error_log("Error: distfile.cpp: request()");
+ return R_PF_ERROR_ADDING_TO_PROXY_QUEUE;
}
- close(sockfd);
- return R_PF_ERROR_ADDING_TO_PROXY_QUEUE;
}
bool Tdistfile::allows_new_actions(){
-// if (downloaded) return false;
-// else return true;
-// int time_left=0;
- if (status==DDOWNLOADED){
- debug("No new connection for distfile:"+name+". Distfile has DDOWNLOADED status");
- return false;
- }
- if (status==DFAILED){
- 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){
- debug("Allow new connection for ============================================= Distfile "+name);
- debug("max_connection limit has not been reached");
- return true;
- }else{
- debug("No new connection for distfile: "+name+". It already has "
- +toString(active_connections_num)
- +" connections => choose another distfile.");
+ try{
+ if (status==DDOWNLOADED){
+ debug("No new connection for distfile:"+name+". Distfile has DDOWNLOADED status");
+ return false;
+ }
+ if (status==DFAILED){
+ 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;
+ }
+ if (active_connections_num<settings.max_connection_num_per_distfile){
+ debug("Allow new connection for ============================================= Distfile "+name);
+ debug("max_connection limit has not been reached");
+ return true;
+ }else{
+ debug("No new connection for distfile: "+name+". It already has "
+ +toString(active_connections_num)
+ +" connections => choose another distfile.");
+ return false;
+ }
+ }catch(...){
+ error_log("Error: distfile.cpp: allows_new_actions()");
+ return true;
}
-// if (((status==DPROXY_QUEUED) || (status==DPROXY_DOWNLOADING)) && (time_left<100)) return false;
-//oterwise allow connections
-// DNEW,
-// D_NOT_PROXY_REQUESTED,
-// DPROXY_REJECTED,
-// DPROXY_FAILED,
-// DPROXY_DOWNLOADED,
-// DWAITING,
-// DDOWNLOADING,json_object_object_get(json_obj_distfile,"SHA512")
}
void Tdistfile::init(){
@@ -624,16 +620,6 @@ uint Tdistfile::request_proxy_fetcher_network(uint network_priority){
}
}
if (best_proxy_fetcher_network_num!=-1) break;
-/*
- }else{
- if (network_array[network_num].only_local_when_possible){
- if (network_distfile_brokers_array[network_num].some_mirrors_have_NOT_failed_yet()){
- allow_remote_mirrors=false;
- debug("Network"+toString(network_num)+" forbids using remote mirrors because not all local mirrors have failed");
- }
- }
- }
-*/
}
}
}
diff --git a/seggetd/mirror.cpp b/seggetd/mirror.cpp
index 5144e9b..a942b2f 100644
--- a/seggetd/mirror.cpp
+++ b/seggetd/mirror.cpp
@@ -133,5 +133,4 @@ Tmirror* find_mirror(string mirror_url){
error_log("Error in mirror.cpp: find_mirror()");
return 0;
}
-}
-
+} \ No newline at end of file
diff --git a/seggetd/network0.conf b/seggetd/network0.conf
index ccc4586..97aa8df 100644
--- a/seggetd/network0.conf
+++ b/seggetd/network0.conf
@@ -198,7 +198,7 @@ user_agent=segget
# append :[port] to the end of the host name. The proxy string may be prefixed
# with [protocol]:// since any such prefix will be ignored. The proxy's port
# number may optionally be specified with the separate option. If not specified,
-# by default port 1080 will be used for proxies.
+# by default port 3128 will be used for proxies.
# When you tell segget to use an HTTP proxy, segget will transparently convert
# operations to HTTP even if you specify an FTP URL etc.
# Segget respects the environment variables http_proxy, ftp_proxy, all_proxy etc,
@@ -209,7 +209,7 @@ user_agent=segget
proxy_ip_or_name=none
# PROXY_PORT
-# Set the proxy port to connect to unless it is specified in the PROXY option.
+# Set the proxy port to connect to unless it is specified in the PROXY_IP_OR_NAME option.
# Minimum value: 1
# Maximum value: 65535
# Default:
@@ -262,7 +262,7 @@ proxy_fetcher_ip=none
# PROXY_FETCHER_PORT
# This option is active only when NETWORK_MODE=1, in other cases it's ignored.
-# Specify proxy-fetcher address
+# Specify port for proxy-fetcher
# Default:
# proxy_fetcher_port=3131
proxy_fetcher_port=3131
diff --git a/seggetd/networkbroker.cpp b/seggetd/networkbroker.cpp
index 36e3d7e..1137017 100644
--- a/seggetd/networkbroker.cpp
+++ b/seggetd/networkbroker.cpp
@@ -46,52 +46,39 @@ void Tnetwork_distfile_broker::init(ulong network_number){
}
void Tnetwork_distfile_broker::local_mirror_failed(uint mirror_num){
- if (phase==E_USE_AS_LOCAL_MIRRORS){
- if (! mirror_fails_vector[mirror_num]){
- mirror_fails_vector[mirror_num]=true;
- failed_mirrors_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;
+ try{
+ if (phase==E_USE_AS_LOCAL_MIRRORS){
+ if (! mirror_fails_vector[mirror_num]){
+ mirror_fails_vector[mirror_num]=true;
+ failed_mirrors_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;
+ }
}
}
+ }catch(...){
+ error_log("Error in networkbroker.cpp: local_mirror_failed()");
}
}
void Tnetwork_distfile_broker::proxy_fetcher_mirror_failed(uint mirror_num){
- if (phase==E_PROXY_FETCHER_DOWNLOADED){
- if (! mirror_fails_vector[mirror_num]){
- mirror_fails_vector[mirror_num]=true;
- failed_mirrors_num++;
- }
- if (failed_mirrors_num>=mirror_fails_vector.size()){
- phase=E_ALL_PROXY_FETCHER_MIRRORS_FAILED;
- failed_mirrors_num=0;
- }
- }
-}
-
-/*
-bool Tnetwork_distfile_broker::some_mirrors_have_NOT_failed_yet(){
try{
- if (failed_mirrors_num<mirror_fails_vector.size()){
- return false;
- }else{
- return true;
+ if (phase==E_PROXY_FETCHER_DOWNLOADED){
+ if (! mirror_fails_vector[mirror_num]){
+ mirror_fails_vector[mirror_num]=true;
+ failed_mirrors_num++;
+ }
+ if (failed_mirrors_num>=mirror_fails_vector.size()){
+ phase=E_ALL_PROXY_FETCHER_MIRRORS_FAILED;
+ failed_mirrors_num=0;
+ }
}
-// for (ulong cur_mirror_num=0; cur_mirror_num<mirror_fails_vector.size();cur_mirror_num++){
-// if (! mirror_fails_vector[cur_mirror_num]){
-// return true;
-// }
-// }
-// return false;
}catch(...){
- error_log("Error in networkbroker.cpp: init()");
- return false;
+ error_log("Error in networkbroker.cpp: proxy_fetcher_mirror_failed()");
}
-}
-*/ \ No newline at end of file
+} \ No newline at end of file
diff --git a/seggetd/phase.cpp b/seggetd/phase.cpp
index 04aef35..ea98dd9 100644
--- a/seggetd/phase.cpp
+++ b/seggetd/phase.cpp
@@ -25,13 +25,19 @@
*/
#include "phase.h"
+#include "log.h"
string phaseToString(int phase_num){
- switch(phase_num){
- case E_USE_AS_LOCAL_MIRRORS: return "E_USE_AS_LOCAL_MIRRORS";
- case E_ALL_LOCAL_MIRRORS_FAILED: return "E_ALL_LOCAL_MIRRORS_FAILED";
- case E_PROXY_FETCHER_DOWNLOADED: return "E_PROXY_FETCHER_DOWNLOADED";
- case E_ALL_PROXY_FETCHER_MIRRORS_FAILED: return "E_ALL_PROXY_FETCHER_MIRRORS_FAILED";
- default: return "Unknown phase";
+ try{
+ switch(phase_num){
+ case E_USE_AS_LOCAL_MIRRORS: return "E_USE_AS_LOCAL_MIRRORS";
+ case E_ALL_LOCAL_MIRRORS_FAILED: return "E_ALL_LOCAL_MIRRORS_FAILED";
+ case E_PROXY_FETCHER_DOWNLOADED: return "E_PROXY_FETCHER_DOWNLOADED";
+ case E_ALL_PROXY_FETCHER_MIRRORS_FAILED: return "E_ALL_PROXY_FETCHER_MIRRORS_FAILED";
+ default: return "Unknown phase";
+ }
+ }catch(...){
+ error_log("Error in phase.cpp: phaseToString()");
+ return "Unknown phase";
}
-}
+} \ No newline at end of file
diff --git a/seggetd/pkg.cpp b/seggetd/pkg.cpp
index 737bb5d..20a92b8 100644
--- a/seggetd/pkg.cpp
+++ b/seggetd/pkg.cpp
@@ -29,13 +29,6 @@ Tpkg **Ppkg_array;
Tpkg proxy_fetcher_pkg;
Tpkg request_server_pkg;
-//#define R_DOWNLOAD_STARTED 0
-//#define R_ADDED_TO_PROXY_QUEUE 100
-//#define R_ALREADY_WAS_IN_QUEUE 101
-//#define R_WAIT_FOR_LOCAL_MIRRORS 102
-//#define R_NO_FREE_NETWORK_CONNECTION_FOUND 103
-//#define R_ERROR_ADDING_TO_PROXY_QUEUE 200
-
int Tpkg::push_back_distfile(json_object* json_obj_distfile){
try{
Tdistfile * Pcur_distfile=new Tdistfile();
@@ -92,29 +85,9 @@ void Tpkg::load_distfile_list(json_object* json_array_distfile_list){
error_log("Error in pkg.cpp: load_distfile_list()");
}
}
-/*
-void Tpkg::load_distfile_list(json_object* json_array_distfile_list){
- try{
- distfile_count=json_object_array_length(json_array_distfile_list);
-// Pdistfile_list= new Tdistfile* [distfile_count];
- for(uint distfile_array_item_num=0;distfile_array_item_num<distfile_count;distfile_array_item_num++){
-// Pdistfile_list[distfile_array_item_num]=new Tdistfile();
- Pdistfile_list.push_back(new Tdistfile());
-// Tdistfile a_distfile;
-// a_distfile.load_distfile_from_json(json_object_array_get_idx(json_array_distfile_list,distfile_array_item_num));
- Pdistfile_list[distfile_array_item_num]->load_distfile_from_json(json_object_array_get_idx(json_array_distfile_list,distfile_array_item_num));
- }
- }catch(...){
- error_log("Error in pkg.cpp: load_distfile_list()");
- }
-}
-*/
-
-
void Tpkg::load_pkg_from_json(json_object* json_obj_pkg){
try{
- // printf("\t%d %s\n",array_item_num, json_object_to_json_string(json_obj_pkg));
name=json_object_to_json_string(json_object_object_get(json_obj_pkg,"pkg_name"));
category=json_object_to_json_string(json_object_object_get(json_obj_pkg,"CATEGORY"));
load_distfile_list(json_object_object_get(json_obj_pkg,"distfile_list"));
@@ -128,7 +101,6 @@ Tpkg::~Tpkg(){
for (uint i=0;i<distfile_count;i++)
delete Pdistfile_list[i];
Pdistfile_list.clear();
-// delete [] Pdistfile_list;
}catch(...){
error_log("Error in pkg.cpp: ~Tpkg");
}
diff --git a/seggetd/proxyfetcher.cpp b/seggetd/proxyfetcher.cpp
index 6f91680..daf4651 100644
--- a/seggetd/proxyfetcher.cpp
+++ b/seggetd/proxyfetcher.cpp
@@ -143,4 +143,4 @@ void *run_proxy_fetcher_server(void * ){
error_log("Error in proxyfetcher.cpp: run_proxy_fetcher_server()");
return (void*)1;
}
-}
+} \ No newline at end of file
diff --git a/seggetd/requestserver.cpp b/seggetd/requestserver.cpp
index 7fd76d3..cfb6ab8 100644
--- a/seggetd/requestserver.cpp
+++ b/seggetd/requestserver.cpp
@@ -142,4 +142,4 @@ void *run_request_server(void * ){
error_log("Error in requestserver.cpp: run_request_server()");
return (void*)1;
}
-}
+} \ No newline at end of file
diff --git a/seggetd/response.cpp b/seggetd/response.cpp
index f8456c0..9dbdfef 100644
--- a/seggetd/response.cpp
+++ b/seggetd/response.cpp
@@ -63,5 +63,4 @@ int decode_server_response(string server_response){
return R_PF_FAILED;
};
}
-}
-
+} \ No newline at end of file
diff --git a/seggetd/seggetd.conf b/seggetd/seggetd.conf
index 3bfb7b0..51bbfbb 100644
--- a/seggetd/seggetd.conf
+++ b/seggetd/seggetd.conf
@@ -291,14 +291,14 @@ rss_description=Files downloaded by seggetd and provided in the local mirror
# with segget daemon (request_server part of it).
# REQUEST_IP
-# Define an ip address segget will use to provide access for tuiclients.
+# Define an ip address segget will use to provide access for request tool.
# The parameter should be a string holding your host dotted IP address.
# Default:
# request_ip=127.0.0.1
request_ip=127.0.0.1
# REQUEST_PORT
-# Define a port segget will use to provide access for tuiclients.
+# Define a port segget will use to provide access for request tool.
# The parameter should be an integer.
# Minimum value: 1
# Maximum value: 65535
@@ -308,7 +308,7 @@ request_port=10000
[scripting_and_scheduling]
# Segget provides Python scripting functionalyty to support scheduling.
-# Each time segget tries to start a new connection certain network it calls
+# Each time segget tries to start a new connection via certain network it calls
# a python script (client.py) to accept or reject this connection and
# if necessary adjusts its settings.
diff --git a/seggetd/seggetd.cpp b/seggetd/seggetd.cpp
index a392ffa..593e20b 100644
--- a/seggetd/seggetd.cpp
+++ b/seggetd/seggetd.cpp
@@ -25,78 +25,6 @@
*/
#include "seggetd.h"
-/*
-int load_pkgs(){
- try{
-
- ifstream json_pkg_list_file;
- json_pkg_list_file.exceptions (ofstream::failbit | ofstream::badbit);
- try{
- json_pkg_list_file.open((settings.pkg_list_dir+"/pkg.list").c_str());
- }catch(...){
- error_log("Error: Can't open "+settings.pkg_list_dir+"/pkg.list"+" file");
- return 1;
- }
- string buff((std::istreambuf_iterator<char>(json_pkg_list_file)), std::istreambuf_iterator<char>());
- try{
- json_pkg_list_file>>buff;
- }catch(std::ifstream::failure e){
- if (!json_pkg_list_file.eof()){
- error_log("Error: Can't read pkg.list file: "+(string)e.what());
- return 1;
- }
- }catch(...){
- error_log("Unknown Error: Can't read pkg.list file");
- return 1;
- }
- try{
- json_pkg_list_file.close();
- }catch(...){
- error_log("Error: Can't close pkg.list file");
- }
- try{
- // cout<< buff<<"\n";
- json_object *json_array_pkg_list;
- json_array_pkg_list = json_tokener_parse(buff.c_str());
- if (is_error(json_array_pkg_list))
- printf("error parsing json: %s\n",json_tokener_errors[-(unsigned long)json_array_pkg_list]);
- else {
- stats.pkg_count=json_object_array_length(json_array_pkg_list);
- Ppkg_array= new Tpkg* [stats.pkg_count];
- // create 0 pkg for distfiles to provide proxy-fetcher
- for(uint array_item_num=0;array_item_num<stats.pkg_count;array_item_num++){
- Ppkg_array[array_item_num]=new Tpkg;
- Ppkg_array[array_item_num]->load_pkg_from_json(json_object_array_get_idx(json_array_pkg_list,array_item_num));
- }
- }
- return 0;
- }catch(...){
- error_log("Error: Can't parse json data from pkg.list file");
- return 1;
- }
- }catch(...){
- error_log("Error in segget.cpp: load_pkgs()");
- return 1;
- }
-}
-*/
-/*
-void show_pkgs(){
- try{
- for (uint array_item_num=0;array_item_num<stats.pkg_count;array_item_num++){
- cout <<"PKG:"<<array_item_num<<") cat:"<< Ppkg_array[array_item_num]->category <<" name:"<< Ppkg_array[array_item_num]->name <<"\n";
- for(uint distfile_array_item_num=0;distfile_array_item_num<Ppkg_array[array_item_num]->distfile_count;distfile_array_item_num++){
- cout << " "<< distfile_array_item_num<<") distfile_name:"<< Ppkg_array[array_item_num]->Pdistfile_list[distfile_array_item_num]->name<<"\n";
- for(uint urllist_array_item_num=0;urllist_array_item_num<Ppkg_array[array_item_num]->Pdistfile_list[distfile_array_item_num]->url_count;urllist_array_item_num++){
- cout <<" "<<Ppkg_array[array_item_num]->Pdistfile_list[distfile_array_item_num]->url_list[urllist_array_item_num]<<"\n";
- }
- }
- }
- }catch(...){
- error_log("Error in segget.cpp: show_pkgs()");
- }
-}
-*/
int pkg_choose_segment(Tpkg * cur_pkg, uint connection_num){
try{
uint distfile_num(0);
@@ -144,13 +72,6 @@ int pkg_choose_segment(Tpkg * cur_pkg, uint connection_num){
int choose_segment(uint connection_num){
try{
debug("Entered choose_segment()");
-// for (uint pkg_num=0; pkg_num<stats.pkg_count; pkg_num++){
-// debug("pkg_num:"+toString(pkg_num));
-// if (0==pkg_choose_segment(Ppkg_array[pkg_num], connection_num)){
-// return 0;
-// }
-// }
-
if (0==pkg_choose_segment(&request_server_pkg, connection_num)){
return 0;
}
@@ -159,12 +80,6 @@ int choose_segment(uint connection_num){
if (0==pkg_choose_segment(&proxy_fetcher_pkg, connection_num)){
return 0;
}
- // for (uint array_item_num=0;array_item_num<pkg_count;array_item_num++){
- //for(int distfile_array_item_num=0;distfile_array_item_num<Ppkg_array[array_item_num]->distfile_count;distfile_array_item_num++){
- // if (Ppkg_array[array_item_num]->Pdistfile_list[distfile_array_item_num]->url_count)
- // Ppkg_array[array_item_num]->Pdistfile_list[distfile_array_item_num]->dosegments();
- //}
- //}
return 1;
}catch(...){
error_log("Error: segget.cpp : choose_segment()");
@@ -173,7 +88,6 @@ int choose_segment(uint connection_num){
}
int download_pkgs(){
try{
- // cout << "Need to download: " << segments_count << " segments\n";
CURLMsg *msg;
long L;
int M, Q, U = -1;
@@ -189,12 +103,6 @@ int download_pkgs(){
return EXIT_FAILURE;
}
-// for (uint connection_num = 0; connection_num < settings.max_connections; ++connection_num) {
-// if ( ! connection_array[connection_num].active){
-// if (choose_segment(connection_num))
-// break;
-// }
-// };
bool keep_running_flag=true;
struct timeval prev_connection_activation_cycle_time;
while (keep_running_flag) {
@@ -226,21 +134,17 @@ int download_pkgs(){
debug("After attempt to start connection activation cycle");
U=stats.active_connections_counter;
debug("before multi_perform");
-// while (CURLM_CALL_MULTI_PERFORM == curl_multi_perform(cm, &U)){};
if (CURLM_CALL_MULTI_PERFORM != curl_multi_perform(cm, &U)){
debug("after multi_perform");
-// if (U) {
FD_ZERO(&R);
FD_ZERO(&W);
FD_ZERO(&E);
if (curl_multi_fdset(cm, &R, &W, &E, &M)) {
error_log("Error: curl_multi_fdset");
-// fprintf(stderr, "E: curl_multi_fdset\n");
return EXIT_FAILURE;
}
if (curl_multi_timeout(cm, &L)) {
error_log("Error: curl_multi_timeout");
-// fprintf(stderr, "E: curl_multi_timeout\n");
return EXIT_FAILURE;
}
if (L == -1)
@@ -255,12 +159,10 @@ int download_pkgs(){
T.tv_sec = L/1000;
T.tv_usec = (L%1000)*1000;
if (0 > select(M+1, &R, &W, &E, &T)) {
-// fprintf(stderr, "E: select(%i,,,,%li): %i: %s\n",
error_log("Error: select ("+toString(M+1)+","+toString(L)+"):"+toString(errno)+": "+strerror(errno));
return EXIT_FAILURE;
}
}
-// }
debug("before multi_info_read");
while ((msg = curl_multi_info_read(cm, &Q))) {
debug("inside multi_info_read");
@@ -268,16 +170,8 @@ int download_pkgs(){
Tsegment *current_segment;
CURL *e = msg->easy_handle;
curl_easy_getinfo(msg->easy_handle, CURLINFO_PRIVATE, &current_segment);
-// CURLcode connection_result=msg->data.result;
-// string result_msg_text="RESULT:"+toString(connection_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);
-
connection_array[current_segment->connection_num].stop(msg->data.result);
-
-// if (not choose_segment(current_segment->connection_num)) {
-// U++; // just to prevent it from remaining at 0 if there are more URLs to get
-// };
stats.show_totals();
curl_easy_cleanup(e);
}else {
@@ -327,7 +221,6 @@ void launch_proxy_fetcher_server_thread(){
pthread_t proxy_fetcher_server_thread;
int iret1;
debug_no_msg("Creating ui_server_thread.");
-// proxy_fetcher_server_thread.init();
iret1 = pthread_create( &proxy_fetcher_server_thread, NULL, run_proxy_fetcher_server, (void*) NULL);
debug_no_msg("proxy_fetcher_server_thread launched");
}
@@ -338,23 +231,10 @@ void launch_request_server_thread(){
pthread_t request_server_thread;
int iret1;
debug_no_msg("Creating request_server_thread.");
-// proxy_fetcher_server_thread.init();
iret1 = pthread_create( &request_server_thread, NULL, run_request_server, (void*) NULL);
debug_no_msg("request_server_thread launched");
}
}
-/*
-void launch_script_server_thread(){
-// if (settings.request_ip!="none"){
- pthread_t script_server_thread;
- int iret1;
- debug_no_msg("Creating script_server_thread.");
-// proxy_fetcher_server_thread.init();
- iret1 = pthread_create( &script_server_thread, NULL, run_script_server, (void*) NULL);
- debug_no_msg("script_server_thread launched");
-// }
-}
-*/
void segget_exit(int sig){
try{
endwin();
@@ -384,13 +264,12 @@ int routine(){
signal(SIGINT,segget_exit);//If program terminates go to assigned function "segget_exit".
try{
gettimeofday(&stats.segget_start_time,NULL);
-// stats.prev_time=time((time_t *)NULL);
}catch(...){
error_log("Error in stats.cpp: reset_previous_time()");
}
try{
//load settings
- settings.init();
+ settings.init();
}
catch(...)
{
@@ -417,13 +296,6 @@ int routine(){
}catch(...){
error_log_no_msg("Error in segget.cpp launch_proxy_fetcher_server_thread failed");
}
-/*
- try{
- launch_script_server_thread();
- }catch(...){
- error_log_no_msg("Error in segget.cpp launch_script_server_thread failed");
- }
-*/
try{
launch_proxy_fetcher_server_thread();
}catch(...){
@@ -434,11 +306,6 @@ int routine(){
}catch(...){
error_log_no_msg("Error in segget.cpp launch_tui_theread() failed");
}
-// try{
-// load_pkgs();
-// }catch(...){
- //error while loading pkgs
-// }
try{
//show_pkgs();
stats.show_totals();
@@ -492,12 +359,10 @@ void start_daemon_mode(){
//stdout
if (dup(fileDesc)){
log_no_msg("Error in segget.cpp: start_daemon_mode: during dup(fileDesc) - stdout");
-// exit(1);
}
//stderr
if (dup(fileDesc)){
log_no_msg("Error in segget.cpp: start_daemon_mode: during dup(fileDesc) - stderr");
-// exit(1);
}
log_no_msg("Starting daemon routine");
routine();
@@ -519,6 +384,19 @@ int init_curses(){
}
return 1;
}
+void show_help(){
+ try{
+ cout << "Usage: seggetd [OPTIONS]" << endl;
+ cout << "OPTIONS:" << endl;
+ cout << "--conf-dir=path Use .conf files from specified dir instead of default /etc/seggetd" << endl;
+ cout << "--help Show this help" << endl;
+ cout << "--no-daemon Do NOT switch to daemon mode on start" << endl;
+ exit (0);
+ }catch(...){
+ perror("Error in segget.cpp show_help()");
+ }
+}
+
int parse_cli_arguments(int argc, char* argv[]){
try{
string option,name,value;
@@ -530,6 +408,7 @@ int parse_cli_arguments(int argc, char* argv[]){
posEqual=option.find('=');
name = trim(option.substr(0,posEqual));
value = trim(option.substr(posEqual+1));
+ if (name=="--help") {show_help(); continue;};
if (name=="--conf-dir") {settings.conf_dir=value; continue;};
if (name=="--no-daemon"){settings.no_daemon_flag=true; continue;}
}
diff --git a/seggetd/segment.cpp b/seggetd/segment.cpp
index b771948..fd56da4 100644
--- a/seggetd/segment.cpp
+++ b/seggetd/segment.cpp
@@ -29,12 +29,17 @@
Tsegment *segments_in_progress[MAX_CONNECTS]={0};
string statusToString(Tsegment_status the_status){
- switch (the_status){
- case SWAITING:return "SWAITING";
- case SDOWNLOADING:return "SDOWNLOADING";
- case SDOWNLOADED:return "SDOWNLOADED";
- case SFAILED:return "SFAILED";
- default :return "UNKNOWN STATUS";
+ try{
+ switch (the_status){
+ case SWAITING:return "SWAITING";
+ case SDOWNLOADING:return "SDOWNLOADING";
+ case SDOWNLOADED:return "SDOWNLOADED";
+ case SFAILED:return "SFAILED";
+ default :return "UNKNOWN STATUS";
+ }
+ }catch(...){
+ error_log("Error in segment.cpp: statusToString()");
+ return "UNKNOWN STATUS";
}
}
bool Tsegment::segment_verification_is_ok(){
@@ -88,7 +93,6 @@ uint Tsegment::start(CURLM *cm, uint con_num, uint network_num, uint distfile_nu
status=SDOWNLOADING;
downloaded_bytes=0;
connection_num=con_num;
-// connection_array[con_num].start(network_num);
try_num++;
return add_easy_handle_to_multi(cm, network_num);
}catch(...){
@@ -223,10 +227,6 @@ size_t write_data(void *buffer, size_t size, size_t nmemb, void *cur_segment){
error_log("Can't write segment file:"+segment->file_name);
}
connection_array[segment->connection_num].inc_bytes_per_last_interval(bytes_written);
-// ulong time_diff_msecs=time_left_from(stats.previous_time);
-// if (time_diff_msecs >= settings.current_speed_time_interval_msecs){
-// show_progress(time_diff_msecs);
-// };
}catch(...){
error_log("Error in segment.cpp: write_data()");
return 0;
diff --git a/seggetd/stats.cpp b/seggetd/stats.cpp
index 7bff34e..6026a1e 100644
--- a/seggetd/stats.cpp
+++ b/seggetd/stats.cpp
@@ -31,13 +31,6 @@ Tstats stats;
void Tstats::inc_dld_distfiles_count(){
try{
dld_distfiles_count++;
-// if ((settings.del_pkg_list_when_dld_finished) and (dld_distfiles_count>distfiles_count)){
- //delete pkg.list file;
-// if(remove((settings.pkg_list_dir+"/pkg.list").c_str()) != 0 )
-// error_log("Error in stats.cpp: inc_dld_distfiles_count(): Can't delete:"+settings.pkg_list_dir+"/pkg.list");
-// else
-// debug(settings.pkg_list_dir+"/pkg.list"+" deleted" );
-// }
}catch(...){
error_log("Error in stats.cpp: show_totals()");
}
@@ -65,22 +58,16 @@ void Tstats::show_totals(){
msg_total("Total CON:"
+field("", active_connections_counter,2)+"/"
+field("", settings.max_connections,2)
-// +field(" PKGs:", pkg_count,4)
-// +field(" = DFs:", dld_distfiles_count,4)
+" = DF:"+toString(dld_distfiles_count)
+field("/", distfiles_count,4)
+" = Sg:"+toString(dld_segments_count)
+field("/", segments_count,5)
-// +field(" = Size:", dld_size/1000,7)
+" = Size:"+toString(dld_size/1000)
+field("(", ((double)dld_size/show_total_size)*100,3)+"%)"
-// +field("/", total_size/1000,7)+" Kb "
+"/"+toString(total_size/1000)+"Kb"
+" Total spd: "+speedToString(total_bytes_per_last_interval*1000/show_last_time_interval)
+avg_speed_str
+eta_str
- // +" Secs:"+toString(now_timee.tv_sec)
- // +" usecs:"+toString(now_timee.tv_usec)
);
reset_previous_time();
}catch(...){
diff --git a/seggetd/str.cpp b/seggetd/str.cpp
index cc7e813..015a8ba 100644
--- a/seggetd/str.cpp
+++ b/seggetd/str.cpp
@@ -71,28 +71,6 @@ vector <string> split_to_vector(string splitter, string str){
return parts;
}
-/*
-template<typename T> string toString(T t){
- stringstream s;
- s << t;
- return s.str();
-}
-*/
-/*
-template<typename T> string field(string prefix,T t, int width){
- try{
- stringstream s1,s2;
- s1 << t;
- width=width+prefix.length();
- s2.width(width);
- s2 << prefix+s1.str();
- return s2.str();
- }catch(...){
- error_log("Error in str.cpp: field()");
- return "";
- }
-}
-*/
string field(string prefix,ulong t, int width){
try{
stringstream s1,s2;
diff --git a/seggetd/tui.cpp b/seggetd/tui.cpp
index 2357fe7..15bda38 100644
--- a/seggetd/tui.cpp
+++ b/seggetd/tui.cpp
@@ -29,27 +29,20 @@ extern Tsettings settings;
const uint CONNECTION_LINES=3;
string screenlines[DEBUG_LINE_NUM+1];
-//vector<string> log_lines;
uint log_lines_counter=0;
uint max_published_screenline_num;
-//bool msg_idle=true;
void msg(uint y, uint x, string msg_text){
-// if (msg_idle){
-// msg_idle=false;
try{
if (max_published_screenline_num<y && y<MAX_LINES) max_published_screenline_num=y;
screenlines[y]=msg_text;
ui_server.send_connection_msg_to_all_clients(y,msg_text);
-// string ready_msg_text=msg_text+" ";
string ready_msg_text=msg_text+"";
mvaddstr(y,x,ready_msg_text.c_str());
refresh();
}catch(...){
error_log_no_msg("Error in tui.cpp: msg()");
}
-// msg_idle=true;
-// }
}
void msg_segment_progress(uint connection_num, string progress_text){
@@ -82,7 +75,6 @@ void msg_clean_connection(uint connection_num){
void msg_log(string log_text){
try{
ui_server.send_log_msg_to_all_clients(log_text);
-// msg(20,0, error_text);
}catch(...){
error_log_no_msg("Error in tui.cpp: msg_error()");
}
@@ -90,7 +82,6 @@ void msg_log(string log_text){
void msg_error_log(string error_log_text){
try{
ui_server.send_error_log_msg_to_all_clients(error_log_text);
-// msg(20,0, error_text);
}catch(...){
error_log_no_msg("Error in tui.cpp: msg_error()");
}
diff --git a/seggetd/ui_server.cpp b/seggetd/ui_server.cpp
index c92f079..3d06e2c 100644
--- a/seggetd/ui_server.cpp
+++ b/seggetd/ui_server.cpp
@@ -35,9 +35,10 @@ enum TDFsearch_rusults{
};
void Tui_server::init(){
- socklen_t server_len;
- struct sockaddr_in server_address;
- // Create and name a socket for the server:
+ try{
+ socklen_t server_len;
+ struct sockaddr_in server_address;
+ // Create and name a socket for the server:
server_sockfd = socket(AF_INET, SOCK_STREAM, 0);
// Set socket options. We would like the socket to disappear
// as soon as it has been closed for whatever reason.
@@ -62,61 +63,57 @@ void Tui_server::init(){
+":"+toString(ntohs(server_address.sin_port)));
}
//Create a connection queue and initialize readfds to handle input from server_sockfd:
- listen(server_sockfd, 5);
- FD_ZERO(&readfds);
- FD_SET(server_sockfd, &readfds);
- send_to_fd_busy=false;
+ listen(server_sockfd, 5);
+ FD_ZERO(&readfds);
+ FD_SET(server_sockfd, &readfds);
+ send_to_fd_busy=false;
+ }catch(...){
+ error_log("Error in ui_server.cpp: init()");
+ }
}
//prevent simultaneous writes
ulong Tui_server::send_binary_to_fd(uint fd, string image_file_name){
-// if (send_to_fd_idle) {
- ifstream image_file;
- try{
- image_file.open (image_file_name.c_str(), ios::in|ios::binary|ios::ate);
- // file.open((settings.conf_dir+"/"+config_file_name).c_str());
- }
- catch(...){
- error_log("Error opening image file: ");
- // return;
+ ifstream image_file;
+ try{
+ image_file.open (image_file_name.c_str(), ios::in|ios::binary|ios::ate);
+ }
+ catch(...){
+ error_log("Error opening image file: ");
+ }
+ try{
+ //processing file
+ ifstream::pos_type size;
+ char * memblock;
+ if (image_file.is_open()){
+ size = image_file.tellg();
+ memblock = new char [size];
+ image_file.seekg (0, ios::beg);
+ image_file.read (memblock, size);
+ while (send_to_fd_busy){
+ sleep(1);
}
- try{
- //processing file
- ifstream::pos_type size;
- char * memblock;
- if (image_file.is_open()){
- size = image_file.tellg();
- memblock = new char [size];
- image_file.seekg (0, ios::beg);
- image_file.read (memblock, size);
-
- while (send_to_fd_busy){
- sleep(1);
+ send_to_fd_busy=true;
+ if (fd !=server_sockfd){
+ if(FD_ISSET(fd,&ui_server.readfds)) {
+ ulong bytes_written=write(fd, memblock, size);
+ if (bytes_written!=size){
+ debug("Error: Not all data has been sent to ui_client during send_binary_to_fd()");
}
- send_to_fd_busy=true;
- if (fd !=server_sockfd){
- if(FD_ISSET(fd,&ui_server.readfds)) {
- ulong bytes_written=write(fd, memblock, size);
- if (bytes_written!=size){
- debug("Error: Not all data has been sent to ui_client during send_binary_to_fd()");
- }
- }
- }
- send_to_fd_busy=false;
- image_file.close();
- delete[] memblock;
}
- }catch(ifstream::failure e){
-//
- }catch(...){
- // error_log("Settings file: "+config_file_name+" was opened, but an error occured while reading settings from it.");
}
-
+ send_to_fd_busy=false;
+ image_file.close();
+ delete[] memblock;
+ }
+ }catch(ifstream::failure e){
+ }catch(...){
+ error_log("Error in ui_server.cpp: send_binary_to_fd()");
+ }
return 0;
}
-
ulong Tui_server::send_to_fd(uint fd, string msg){
// if (send_to_fd_idle) {
while (send_to_fd_busy){
@@ -744,4 +741,4 @@ void *run_ui_server(void * ){
}
}
return 0;
-}
+} \ No newline at end of file
diff --git a/seggetd/utils.cpp b/seggetd/utils.cpp
index 851484f..9ffd205 100644
--- a/seggetd/utils.cpp
+++ b/seggetd/utils.cpp
@@ -41,35 +41,39 @@ ulong time_left_since(timeval from_time){
}
string secsToString(ulong secs){
- string result="";
- ulong mins=0;
- ulong hours=0;
- ulong days=0;
- ldiv_t time_div_spliter;
- if (secs>60){
- time_div_spliter = ldiv (secs,60);
- secs=time_div_spliter.rem;
- if (time_div_spliter.quot>60){
- time_div_spliter = ldiv (time_div_spliter.quot,60);
- mins=time_div_spliter.rem;
- if (time_div_spliter.quot>24){
- time_div_spliter = ldiv (time_div_spliter.quot,24);
- hours=time_div_spliter.rem;
- days=time_div_spliter.quot;
- if (days>999) return ("inf");
- result=result+field(" ", days,3)+"d";
+ try{
+ string result="";
+ ulong mins=0;
+ ulong hours=0;
+ ulong days=0;
+ ldiv_t time_div_spliter;
+ if (secs>60){
+ time_div_spliter = ldiv (secs,60);
+ secs=time_div_spliter.rem;
+ if (time_div_spliter.quot>60){
+ time_div_spliter = ldiv (time_div_spliter.quot,60);
+ mins=time_div_spliter.rem;
+ if (time_div_spliter.quot>24){
+ time_div_spliter = ldiv (time_div_spliter.quot,24);
+ hours=time_div_spliter.rem;
+ days=time_div_spliter.quot;
+ if (days>999) return ("inf");
+ result=result+field(" ", days,3)+"d";
+ }else{
+ hours=time_div_spliter.quot;
+ }
+ result=result+field(" ", hours,2)+"h";
}else{
- hours=time_div_spliter.quot;
+ mins=time_div_spliter.quot;
}
- result=result+field(" ", hours,2)+"h";
- }else{
- mins=time_div_spliter.quot;
+ result=result+field(" ", mins,2)+"m";
}
- result=result+field(" ", mins,2)+"m";
+ result=result+field(" ", secs,2)+"s";
+ return result;
+ }catch(...){
+ error_log("Error in utils.cpp: secsToSting()");
+ return "n/a";
}
- result=result+field(" ", secs,2)+"s";
-
- return result;
}
string speedToString(ulong dld_bytes, ulong time_left){