Merge branch 'development' into LTS_development

This commit is contained in:
Thulinma 2019-05-23 12:42:19 +02:00
commit 26c9f964be
8 changed files with 44 additions and 9 deletions

View file

@ -183,7 +183,15 @@ namespace HTTP{
return true; // Success!
}
// reset the data timeout
reqTime = Util::bootSecs();
if (reqTime != Util::bootSecs()){
if (progressCallback != 0){
if (!progressCallback()){
WARN_MSG("Download aborted by callback");
return false;
}
}
reqTime = Util::bootSecs();
}
}
if (getSocket()){
FAIL_MSG("Timeout while retrieving %s (%zu/%" PRIu32 ")", link.getUrl().c_str(),
@ -239,7 +247,15 @@ namespace HTTP{
return true; // Success!
}
// reset the data timeout
reqTime = Util::bootSecs();
if (reqTime != Util::bootSecs()){
if (progressCallback != 0){
if (!progressCallback()){
WARN_MSG("Download aborted by callback");
return false;
}
}
reqTime = Util::bootSecs();
}
}
if (getSocket()){
FAIL_MSG("Timeout while retrieving %s", link.getUrl().c_str());

View file

@ -786,6 +786,13 @@ bool HTTP::Parser::Read(std::string &strbuf){
return parse(strbuf);
}// HTTPReader::Read
/// Checks download completion percentage.
/// Returns zero if that doesn't make sense at the time or cannot be determined.
uint8_t HTTP::Parser::getPercentage() const{
if (!seenHeaders || length < 1){return 0;}
return ((body.length() * 100) / length);
}
/// Attempt to read a whole HTTP response or request from a data buffer.
/// If succesful, fills its own fields with the proper data and removes the response/request
/// from the data buffer.

View file

@ -24,6 +24,7 @@ namespace HTTP{
const std::string &GetHeader(const std::string &i) const;
bool hasHeader(const std::string &i) const;
void clearHeader(const std::string &i);
uint8_t getPercentage() const;
const std::string &GetVar(const std::string &i) const;
std::string getUrl();
std::string allVars();

View file

@ -20,7 +20,6 @@ namespace Util {
static bool thread_handler;///< True while thread handler should be running.
static void childsig_handler(int signum);
static void exit_handler();
static void runCmd(std::string & cmd);
static char* const* dequeToArgv(std::deque<std::string> & argDeq);
static void grim_reaper(void * n);
public:

View file

@ -1272,7 +1272,9 @@ Socket::Connection Socket::Server::accept(bool nonblock){
// we could do this through accept4 with a flag, but that call is non-standard...
if (r < 0){
if ((errno != EWOULDBLOCK) && (errno != EAGAIN) && (errno != EINTR)){
FAIL_MSG("Error during accept: %s. Closing server socket %d.", strerror(errno), sock);
if (errno != EINVAL){
FAIL_MSG("Error during accept: %s. Closing server socket %d.", strerror(errno), sock);
}
close();
}
return Socket::Connection();