about summary refs log tree commit diff
path: root/third_party/nix/src/libstore/pathlocks.cc
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-19T00·02+0100
committerVincent Ambo <tazjin@google.com>2020-05-19T00·04+0100
commit505b6b044b132b28e1501491bcfe6bd68ca1989e (patch)
tree1c1ed8a195f5c94050754316c842a3f8623c6cbe /third_party/nix/src/libstore/pathlocks.cc
parentce99ba42df493bb521f47789fb8902d7693c5b9c (diff)
refactor(3p/nix/libstore): Replace logging.h with glog r/756
Diffstat (limited to 'third_party/nix/src/libstore/pathlocks.cc')
-rw-r--r--third_party/nix/src/libstore/pathlocks.cc19
1 files changed, 11 insertions, 8 deletions
diff --git a/third_party/nix/src/libstore/pathlocks.cc b/third_party/nix/src/libstore/pathlocks.cc
index 7fa32e21a6..986b543845 100644
--- a/third_party/nix/src/libstore/pathlocks.cc
+++ b/third_party/nix/src/libstore/pathlocks.cc
@@ -1,5 +1,6 @@
 #include "pathlocks.hh"
 #include <fcntl.h>
+#include <glog/logging.h>
 #include <sys/file.h>
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -82,7 +83,7 @@ bool PathLocks::lockPaths(const PathSet& paths, const string& waitMsg,
     checkInterrupt();
     Path lockPath = path + ".lock";
 
-    debug(format("locking path '%1%'") % path);
+    DLOG(INFO) << "locking path '" << path << "'";
 
     AutoCloseFD fd;
 
@@ -93,7 +94,9 @@ bool PathLocks::lockPaths(const PathSet& paths, const string& waitMsg,
       /* Acquire an exclusive lock. */
       if (!lockFile(fd.get(), ltWrite, false)) {
         if (wait) {
-          if (waitMsg != "") printError(waitMsg);
+          if (waitMsg != "") {
+            LOG(WARNING) << waitMsg;
+          }
           lockFile(fd.get(), ltWrite, true);
         } else {
           /* Failed to lock this path; release all other
@@ -103,7 +106,7 @@ bool PathLocks::lockPaths(const PathSet& paths, const string& waitMsg,
         }
       }
 
-      debug(format("lock acquired on '%1%'") % lockPath);
+      DLOG(INFO) << "lock acquired on '" << lockPath << "'";
 
       /* Check that the lock file hasn't become stale (i.e.,
          hasn't been unlinked). */
@@ -115,7 +118,7 @@ bool PathLocks::lockPaths(const PathSet& paths, const string& waitMsg,
            a lock on a deleted file.  This means that other
            processes may create and acquire a lock on
            `lockPath', and proceed.  So we must retry. */
-        debug(format("open lock file '%1%' has become stale") % lockPath);
+        DLOG(INFO) << "open lock file '" << lockPath << "' has become stale";
       else
         break;
     }
@@ -139,11 +142,11 @@ void PathLocks::unlock() {
   for (auto& i : fds) {
     if (deletePaths) deleteLockFile(i.second, i.first);
 
-    if (close(i.first) == -1)
-      printError(format("error (ignored): cannot close lock file on '%1%'") %
-                 i.second);
+    if (close(i.first) == -1) {
+      LOG(WARNING) << "cannot close lock file on '" << i.second << "'";
+    }
 
-    debug(format("lock released on '%1%'") % i.second);
+    DLOG(INFO) << "lock released on '" << i.second << "'";
   }
 
   fds.clear();