Merge branch 'development' into LTS_development
This commit is contained in:
		
						commit
						26c9f964be
					
				
					 8 changed files with 44 additions and 9 deletions
				
			
		| 
						 | 
				
			
			@ -183,8 +183,16 @@ namespace HTTP{
 | 
			
		|||
          return true; // Success!
 | 
			
		||||
        }
 | 
			
		||||
        // reset the data timeout
 | 
			
		||||
        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(),
 | 
			
		||||
                 retryCount - loop + 1, retryCount);
 | 
			
		||||
| 
						 | 
				
			
			@ -239,8 +247,16 @@ namespace HTTP{
 | 
			
		|||
          return true; // Success!
 | 
			
		||||
        }
 | 
			
		||||
        // reset the data timeout
 | 
			
		||||
        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());
 | 
			
		||||
        return false;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)){
 | 
			
		||||
      if (errno != EINVAL){
 | 
			
		||||
        FAIL_MSG("Error during accept: %s. Closing server socket %d.", strerror(errno), sock);
 | 
			
		||||
      }
 | 
			
		||||
      close();
 | 
			
		||||
    }
 | 
			
		||||
    return Socket::Connection();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -184,17 +184,25 @@ namespace Controller {
 | 
			
		|||
      if ((*it).substr(0, 7) == "MistOut"){
 | 
			
		||||
        arg_one = Util::getMyPath() + (*it);
 | 
			
		||||
        conn_args[0] = arg_one.c_str();
 | 
			
		||||
        capabilities["connectors"][(*it).substr(7)] = JSON::fromString(Util::Procs::getOutputOf((char**)conn_args));
 | 
			
		||||
        if (capabilities["connectors"][(*it).substr(7)].size() < 1){
 | 
			
		||||
          capabilities["connectors"].removeMember((*it).substr(7));
 | 
			
		||||
        std::string entryName = (*it).substr(7);
 | 
			
		||||
        capabilities["connectors"][entryName] = JSON::fromString(Util::Procs::getOutputOf((char**)conn_args));
 | 
			
		||||
        if (capabilities["connectors"][entryName].size() < 1){
 | 
			
		||||
          capabilities["connectors"].removeMember(entryName);
 | 
			
		||||
        }else if (capabilities["connectors"][entryName]["version"].asStringRef() != PACKAGE_VERSION){
 | 
			
		||||
          WARN_MSG("Output %s version mismatch (%s != " PACKAGE_VERSION ")", entryName.c_str(), capabilities["connectors"][entryName]["version"].asStringRef().c_str());
 | 
			
		||||
          capabilities["connectors"].removeMember(entryName);
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      if ((*it).substr(0, 6) == "MistIn" && (*it) != "MistInfo"){
 | 
			
		||||
        arg_one = Util::getMyPath() + (*it);
 | 
			
		||||
        conn_args[0] = arg_one.c_str();
 | 
			
		||||
        capabilities["inputs"][(*it).substr(6)] = JSON::fromString(Util::Procs::getOutputOf((char**)conn_args));
 | 
			
		||||
        if (capabilities["inputs"][(*it).substr(6)].size() < 1){
 | 
			
		||||
        std::string entryName = (*it).substr(6);
 | 
			
		||||
        capabilities["inputs"][entryName] = JSON::fromString(Util::Procs::getOutputOf((char**)conn_args));
 | 
			
		||||
        if (capabilities["inputs"][entryName].size() < 1){
 | 
			
		||||
          capabilities["inputs"].removeMember((*it).substr(6));
 | 
			
		||||
        }else if (capabilities["inputs"][entryName]["version"].asStringRef() != PACKAGE_VERSION){
 | 
			
		||||
          WARN_MSG("Input %s version mismatch (%s != " PACKAGE_VERSION ")", entryName.c_str(), capabilities["inputs"][entryName]["version"].asStringRef().c_str());
 | 
			
		||||
          capabilities["inputs"].removeMember(entryName);
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -220,6 +220,7 @@ namespace Mist {
 | 
			
		|||
    Util::Config::streamName = streamName;
 | 
			
		||||
   
 | 
			
		||||
    if (config->getBool("json")) {
 | 
			
		||||
      capa["version"] = PACKAGE_VERSION;
 | 
			
		||||
      std::cout << capa.toString() << std::endl;
 | 
			
		||||
      return 0;
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,6 +15,7 @@ int main(int argc, char * argv[]) {
 | 
			
		|||
  mistOut::init(&conf);
 | 
			
		||||
  if (conf.parseArgs(argc, argv)) {
 | 
			
		||||
    if (conf.getBool("json")) {
 | 
			
		||||
      mistOut::capa["version"] = PACKAGE_VERSION;
 | 
			
		||||
      std::cout << mistOut::capa.toString() << std::endl;
 | 
			
		||||
      return -1;
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue