Increase the sleep time between download retries
This commit is contained in:
		
							parent
							
								
									97b1af1cbe
								
							
						
					
					
						commit
						6631a6e1a1
					
				
					 3 changed files with 4 additions and 2 deletions
				
			
		| 
						 | 
					@ -230,7 +230,7 @@ struct CurlDownloader : public Downloader
 | 
				
			||||||
            } catch (DownloadError & e) {
 | 
					            } catch (DownloadError & e) {
 | 
				
			||||||
                attempt++;
 | 
					                attempt++;
 | 
				
			||||||
                if (e.error != Transient || attempt >= options.tries) throw;
 | 
					                if (e.error != Transient || attempt >= options.tries) throw;
 | 
				
			||||||
                auto ms = 25 * (1 << (attempt - 1));
 | 
					                auto ms = options.baseRetryTimeMs * (1 << (attempt - 1));
 | 
				
			||||||
                printMsg(lvlError, format("warning: %s; retrying in %d ms") % e.what() % ms);
 | 
					                printMsg(lvlError, format("warning: %s; retrying in %d ms") % e.what() % ms);
 | 
				
			||||||
                std::this_thread::sleep_for(std::chrono::milliseconds(ms));
 | 
					                std::this_thread::sleep_for(std::chrono::milliseconds(ms));
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -14,6 +14,7 @@ struct DownloadOptions
 | 
				
			||||||
    enum { yes, no, automatic } showProgress = yes;
 | 
					    enum { yes, no, automatic } showProgress = yes;
 | 
				
			||||||
    bool head = false;
 | 
					    bool head = false;
 | 
				
			||||||
    size_t tries = 1;
 | 
					    size_t tries = 1;
 | 
				
			||||||
 | 
					    unsigned int baseRetryTimeMs = 100;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct DownloadResult
 | 
					struct DownloadResult
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -80,7 +80,8 @@ protected:
 | 
				
			||||||
        auto downloader(downloaders.get());
 | 
					        auto downloader(downloaders.get());
 | 
				
			||||||
        DownloadOptions options;
 | 
					        DownloadOptions options;
 | 
				
			||||||
        options.showProgress = DownloadOptions::no;
 | 
					        options.showProgress = DownloadOptions::no;
 | 
				
			||||||
        options.tries = 3;
 | 
					        options.tries = 5;
 | 
				
			||||||
 | 
					        options.baseRetryTimeMs = 1000;
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            return downloader->download(cacheUri + "/" + path, options).data;
 | 
					            return downloader->download(cacheUri + "/" + path, options).data;
 | 
				
			||||||
        } catch (DownloadError & e) {
 | 
					        } catch (DownloadError & e) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue