00001 // This file is part of BOINC. 00002 // http://boinc.berkeley.edu 00003 // Copyright (C) 2008 University of California 00004 // 00005 // BOINC is free software; you can redistribute it and/or modify it 00006 // under the terms of the GNU Lesser General Public License 00007 // as published by the Free Software Foundation, 00008 // either version 3 of the License, or (at your option) any later version. 00009 // 00010 // BOINC is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00013 // See the GNU Lesser General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public License 00016 // along with BOINC. If not, see <http://www.gnu.org/licenses/>. 00017 00018 #ifndef _PERS_FILE_XFER_H 00019 #define _PERS_FILE_XFER_H 00020 00021 #include "client_types.h" 00022 #include "file_xfer.h" 00023 00024 // Default values for exponential backoff 00025 #define PERS_RETRY_DELAY_MIN 60 // 1 minute 00026 #define PERS_RETRY_DELAY_MAX (60*60*4) // 4 hours 00027 #define PERS_GIVEUP (60*60*24*7*2) // 2 weeks 00028 // give up on xfer if this time elapses since last byte xferred 00029 00043 00049 00053 00056 00077 00078 class PERS_FILE_XFER { 00080 int nretry; 00082 double first_request_time; 00083 void do_backoff(); 00084 00085 public: 00086 bool is_upload; 00088 double next_request_time; 00092 double time_so_far; 00095 double last_time; 00098 double last_bytes_xferred; 00099 bool pers_xfer_done; 00101 FILE_XFER* fxp; 00102 FILE_INFO* fip; 00103 00104 PERS_FILE_XFER(); 00105 ~PERS_FILE_XFER(); 00106 int init(FILE_INFO*, bool is_file_upload); 00107 bool poll(); 00108 void transient_failure(int); 00109 void permanent_failure(int); 00110 void abort(); 00111 int write(MIOFILE& fout); 00112 int parse(MIOFILE& fin); 00113 int create_xfer(); 00114 int start_xfer(); 00115 void suspend(); 00116 }; 00117 00118 class PERS_FILE_XFER_SET { 00119 public: 00120 FILE_XFER_SET* file_xfers; 00121 std::vector<PERS_FILE_XFER*>pers_file_xfers; 00122 00123 PERS_FILE_XFER_SET(FILE_XFER_SET*); 00124 int insert(PERS_FILE_XFER*); 00125 int remove(PERS_FILE_XFER*); 00126 bool poll(); 00127 void suspend(); 00128 }; 00129 00130 #endif
1.5.6