Repository: mesos
Updated Branches:
  refs/heads/master 3eaab8a2e -> a4b1134e4


Made OfferOperationStatusUpdateManager tests pass on Windows.

Review: https://reviews.apache.org/r/64522/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/a4b1134e
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/a4b1134e
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/a4b1134e

Branch: refs/heads/master
Commit: a4b1134e4e407d8523e6f1c53aa709fd6aaba003
Parents: 3eaab8a
Author: Gaston Kleiman <[email protected]>
Authored: Fri Dec 15 16:02:35 2017 -0800
Committer: Andrew Schwartzmeyer <[email protected]>
Committed: Fri Dec 15 16:02:35 2017 -0800

----------------------------------------------------------------------
 .../status_update_manager_process.hpp              | 17 +++++++++++++++--
 ...offer_operation_status_update_manager_tests.cpp |  5 ++++-
 2 files changed, 19 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/a4b1134e/src/status_update_manager/status_update_manager_process.hpp
----------------------------------------------------------------------
diff --git a/src/status_update_manager/status_update_manager_process.hpp 
b/src/status_update_manager/status_update_manager_process.hpp
index ce05a8e..5dc2bec 100644
--- a/src/status_update_manager/status_update_manager_process.hpp
+++ b/src/status_update_manager/status_update_manager_process.hpp
@@ -634,6 +634,9 @@ private:
         // Open the updates file.
         Try<int_fd> result = os::open(
             path.get(),
+#ifdef __WINDOWS__
+            O_BINARY |
+#endif // __WINDOWS__
             O_CREAT | O_SYNC | O_WRONLY | O_CLOEXEC,
             S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
 
@@ -667,7 +670,12 @@ private:
       }
 
       // Open the status updates file for reading and writing.
-      Try<int_fd> fd = os::open(path, O_SYNC | O_RDWR | O_CLOEXEC);
+      Try<int_fd> fd = os::open(
+          path,
+#ifdef __WINDOWS__
+          O_BINARY |
+#endif // __WINDOWS__
+          O_SYNC | O_RDWR | O_CLOEXEC);
 
       if (fd.isError()) {
         return Error("Failed to open '" + path + "': " + fd.error());
@@ -754,8 +762,13 @@ private:
         // A stream is created only once there's something to write to it, so
         // this can only happen if the checkpointing of the first update was
         // interrupted.
-        Try<Nothing> removed = os::rm(path);
 
+        // On Windows you can only delete a file if it is not open. The
+        // stream's destructor will close the file, so we need to destroy it
+        // here.
+        stream.reset();
+
+        Try<Nothing> removed = os::rm(path);
         if (removed.isError()) {
           return Error(
               "Failed to remove file '" + path + "': " + removed.error());

http://git-wip-us.apache.org/repos/asf/mesos/blob/a4b1134e/src/tests/offer_operation_status_update_manager_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/offer_operation_status_update_manager_tests.cpp 
b/src/tests/offer_operation_status_update_manager_tests.cpp
index cb71bc1..37bea36 100644
--- a/src/tests/offer_operation_status_update_manager_tests.cpp
+++ b/src/tests/offer_operation_status_update_manager_tests.cpp
@@ -82,9 +82,12 @@ protected:
         forward, OfferOperationStatusUpdateManagerTest::getPath);
   }
 
-  ~OfferOperationStatusUpdateManagerTest()
+  void TearDown() override
   {
     Clock::resume();
+    statusUpdateManager.reset();
+
+    MesosTest::TearDown();
   }
 
   OfferOperationStatusUpdate createOfferOperationStatusUpdate(

Reply via email to