kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ale...@apache.org
Subject [kudu] 01/02: [mini_chronyd] remove cmd socket directory on exit
Date Fri, 04 Oct 2019 17:19:23 GMT
This is an automated email from the ASF dual-hosted git repository.

alexey pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git

commit d41293969d4cd908b7b030ac8a136fb457b50037
Author: Alexey Serbin <alexey@apache.org>
AuthorDate: Thu Oct 3 16:32:22 2019 -0700

    [mini_chronyd] remove cmd socket directory on exit
    
    This patch adds a clean up for chronyd's command socket directory
    created by MiniChronyd.  Also, it removes unused cmd_socket_ member
    of the MiniChronyd class.
    
    Change-Id: I2139857f6312fab0839cf23a6c66b3448c632791
    Reviewed-on: http://gerrit.cloudera.org:8080/14365
    Tested-by: Alexey Serbin <aserbin@cloudera.com>
    Reviewed-by: Grant Henke <granthenke@apache.org>
---
 src/kudu/clock/test/mini_chronyd.cc | 15 ++++++++++++---
 src/kudu/clock/test/mini_chronyd.h  |  3 +--
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/src/kudu/clock/test/mini_chronyd.cc b/src/kudu/clock/test/mini_chronyd.cc
index 7f1d09f..1d86a40 100644
--- a/src/kudu/clock/test/mini_chronyd.cc
+++ b/src/kudu/clock/test/mini_chronyd.cc
@@ -156,7 +156,14 @@ MiniChronyd::MiniChronyd(MiniChronydOptions options)
 
 MiniChronyd::~MiniChronyd() {
   if (process_) {
-    WARN_NOT_OK(Stop(), "unable to stop MiniChronyd");
+    WARN_NOT_OK(Stop(), "unable to stop chronyd");
+  }
+  if (!cmd_socket_dir_.empty()) {
+    // Remove the directory created for the command Unix domain socket. The
+    // directory should be empty if chronyd exited normally: it cleans up after
+    // itself on a clean exit.
+    WARN_NOT_OK(Env::Default()->DeleteDir(cmd_socket_dir_),
+                "unable to remove chronyd command socket directory");
   }
 }
 
@@ -390,14 +397,16 @@ $0
     // TODO(aserbin): use some synthetic mount point instead?
     string dir;
     RETURN_NOT_OK(Env::Default()->GetTestDirectory(&dir));
-    dir += Substitute("/$0.$1", Env::Default()->NowMicros(), getpid());
+    dir = JoinPathSegments(dir, Substitute("$0.$1", Env::Default()->NowMicros(),
+                                           getpid()));
     const auto s = Env::Default()->CreateDir(dir);
-    if (!s.IsAlreadyPresent() && !s.ok()) {
+    if (!s.ok() && !s.IsAlreadyPresent()) {
       return s;
     }
     RETURN_NOT_OK(CorrectOwnership(dir));
     options_.bindcmdaddress = Substitute("$0/chronyd.$1.sock",
                                          dir, options_.index);
+    cmd_socket_dir_ = std::move(dir);
   }
   string username;
   RETURN_NOT_OK(GetLoggedInUser(&username));
diff --git a/src/kudu/clock/test/mini_chronyd.h b/src/kudu/clock/test/mini_chronyd.h
index b7bd45e..c888fe9 100644
--- a/src/kudu/clock/test/mini_chronyd.h
+++ b/src/kudu/clock/test/mini_chronyd.h
@@ -29,7 +29,6 @@
 namespace kudu {
 
 class HostPort;
-class RWFile;
 class Subprocess;
 
 namespace clock {
@@ -249,7 +248,7 @@ class MiniChronyd {
                       std::string* out_stderr = nullptr) const WARN_UNUSED_RESULT;
 
   MiniChronydOptions options_;
-  std::unique_ptr<RWFile> cmd_socket_;
+  std::string cmd_socket_dir_;
   std::unique_ptr<Subprocess> process_;
 };
 


Mime
View raw message