[Cmake-commits] CMake branch, next, updated. v2.8.4-1645-g35ed085

Brad King brad.king at kitware.com
Wed Jun 1 09:59:32 EDT 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  35ed085eca17d84faf37d6a34283e61f86eb53d1 (commit)
       via  faa7ec6e185c535548814f7aafd16c13346b514f (commit)
      from  66e0b0cde5c72eeaaceff445ec3b3d1fbb06de9d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=35ed085eca17d84faf37d6a34283e61f86eb53d1
commit 35ed085eca17d84faf37d6a34283e61f86eb53d1
Merge: 66e0b0c faa7ec6
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Jun 1 09:59:30 2011 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Wed Jun 1 09:59:30 2011 -0400

    Merge topic 'file-DOWNLOAD-low-speed-timeout' into next
    
    faa7ec6 Teach file(DOWNLOAD|UPLOAD) to timeout after inactivity


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=faa7ec6e185c535548814f7aafd16c13346b514f
commit faa7ec6e185c535548814f7aafd16c13346b514f
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Jun 1 09:55:42 2011 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Wed Jun 1 09:55:42 2011 -0400

    Teach file(DOWNLOAD|UPLOAD) to timeout after inactivity
    
    Add option INACTIVITY_TIMEOUT to terminate the operation if there is no
    progress for more than a given amount of time.

diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index d28de08..9a3de9b 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -2614,6 +2614,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
   ++i;
 
   long timeout = 0;
+  long inactivity_timeout = 0;
   std::string verboseLog;
   std::string statusVar;
   std::string expectedMD5sum;
@@ -2634,6 +2635,19 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
         return false;
         }
       }
+    else if(*i == "INACTIVITY_TIMEOUT")
+      {
+      ++i;
+      if(i != args.end())
+        {
+        inactivity_timeout = atol(i->c_str());
+        }
+      else
+        {
+        this->SetError("DOWNLOAD missing time for INACTIVITY_TIMEOUT.");
+        return false;
+        }
+      }
     else if(*i == "LOG")
       {
       ++i;
@@ -2770,6 +2784,13 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
     check_curl_result(res, "DOWNLOAD cannot set timeout: ");
     }
 
+  if(inactivity_timeout > 0)
+    {
+    // Give up if there is no progress for a long time.
+    ::curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1);
+    ::curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, inactivity_timeout);
+    }
+
   // Need the progress helper's scope to last through the duration of
   // the curl_easy_perform call... so this object is declared at function
   // scope intentionally, rather than inside the "if(showProgress)"
@@ -2883,6 +2904,7 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
   ++i;
 
   long timeout = 0;
+  long inactivity_timeout = 0;
   std::string logVar;
   std::string statusVar;
   bool showProgress = false;
@@ -2902,6 +2924,19 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
         return false;
         }
       }
+    else if(*i == "INACTIVITY_TIMEOUT")
+      {
+      ++i;
+      if(i != args.end())
+        {
+        inactivity_timeout = atol(i->c_str());
+        }
+      else
+        {
+        this->SetError("UPLOAD missing time for INACTIVITY_TIMEOUT.");
+        return false;
+        }
+      }
     else if(*i == "LOG")
       {
       ++i;
@@ -3003,6 +3038,13 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
     check_curl_result(res, "UPLOAD cannot set timeout: ");
     }
 
+  if(inactivity_timeout > 0)
+    {
+    // Give up if there is no progress for a long time.
+    ::curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1);
+    ::curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, inactivity_timeout);
+    }
+
   // Need the progress helper's scope to last through the duration of
   // the curl_easy_perform call... so this object is declared at function
   // scope intentionally, rather than inside the "if(showProgress)"
diff --git a/Source/cmFileCommand.h b/Source/cmFileCommand.h
index 1b6dbbf..162890a 100644
--- a/Source/cmFileCommand.h
+++ b/Source/cmFileCommand.h
@@ -80,10 +80,11 @@ public:
       "  file(RELATIVE_PATH variable directory file)\n"
       "  file(TO_CMAKE_PATH path result)\n"
       "  file(TO_NATIVE_PATH path result)\n"
-      "  file(DOWNLOAD url file [TIMEOUT timeout] [STATUS status] [LOG log]\n"
-      "       [EXPECTED_MD5 sum] [SHOW_PROGRESS])\n"
-      "  file(UPLOAD filename url [TIMEOUT timeout] [STATUS status]\n"
-      "       [LOG log] [SHOW_PROGRESS])\n"
+      "  file(DOWNLOAD url file [INACTIVITY_TIMEOUT timeout]\n"
+      "       [TIMEOUT timeout] [STATUS status] [LOG log] [SHOW_PROGRESS]\n"
+      "       [EXPECTED_MD5 sum])\n"
+      "  file(UPLOAD filename url [INACTIVITY_TIMEOUT timeout]\n"
+      "       [TIMEOUT timeout] [STATUS status] [LOG log] [SHOW_PROGRESS])\n"
       "WRITE will write a message into a file called 'filename'. It "
       "overwrites the file if it already exists, and creates the file "
       "if it does not exist.\n"
@@ -161,6 +162,8 @@ public:
       "numeric error means no error in the operation. "
       "If TIMEOUT time is specified, the operation will "
       "timeout after time seconds, time should be specified as an integer. "
+      "The INACTIVITY_TIMEOUT specifies an integer number of seconds of "
+      "inactivity after which the operation should terminate. "
       "If EXPECTED_MD5 sum is specified, the operation will verify that the "
       "downloaded file's actual md5 sum matches the expected value. If it "
       "does not match, the operation fails with an error. "
@@ -176,6 +179,8 @@ public:
       "numeric error means no error in the operation. "
       "If TIMEOUT time is specified, the operation will "
       "timeout after time seconds, time should be specified as an integer. "
+      "The INACTIVITY_TIMEOUT specifies an integer number of seconds of "
+      "inactivity after which the operation should terminate. "
       "If SHOW_PROGRESS is specified, progress information will be printed "
       "as status messages until the operation is complete."
       "\n"

-----------------------------------------------------------------------

Summary of changes:
 Source/cmFileCommand.cxx |   42 ++++++++++++++++++++++++++++++++++++++++++
 Source/cmFileCommand.h   |   13 +++++++++----
 2 files changed, 51 insertions(+), 4 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list