about summary refs log tree commit diff
path: root/src/build-remote/build-remote.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/build-remote/build-remote.cc')
-rw-r--r--src/build-remote/build-remote.cc17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/build-remote/build-remote.cc b/src/build-remote/build-remote.cc
index 1ac9711a1103..2ce20882da17 100644
--- a/src/build-remote/build-remote.cc
+++ b/src/build-remote/build-remote.cc
@@ -5,6 +5,9 @@
 #include <memory>
 #include <tuple>
 #include <iomanip>
+#if __APPLE__
+#include <sys/time.h>
+#endif
 
 #include "shared.hh"
 #include "pathlocks.hh"
@@ -64,7 +67,8 @@ public:
         enabled{true} {};
 };;
 
-static std::vector<machine> read_conf() {
+static std::vector<machine> read_conf()
+{
     auto conf = getEnv("NIX_REMOTE_SYSTEMS", SYSCONFDIR "/nix/machines");
 
     auto machines = std::vector<machine>{};
@@ -104,8 +108,9 @@ static std::vector<machine> read_conf() {
 
 static string currentLoad;
 
-static int openSlotLock(const machine & m, unsigned long long slot) {
-    auto fn_stream = std::stringstream(currentLoad, std::ios_base::ate | std::ios_base::out);
+static AutoCloseFD openSlotLock(const machine & m, unsigned long long slot)
+{
+    std::ostringstream fn_stream(currentLoad, std::ios_base::ate | std::ios_base::out);
     fn_stream << "/";
     for (auto t : m.systemTypes) {
         fn_stream << t << "-";
@@ -181,7 +186,7 @@ int main (int argc, char * * argv)
                         AutoCloseFD free;
                         unsigned long long load = 0;
                         for (unsigned long long slot = 0; slot < m.maxJobs; ++slot) {
-                            AutoCloseFD slotLock = openSlotLock(m, slot);
+                            auto slotLock = openSlotLock(m, slot);
                             if (lockFile(slotLock.get(), ltWrite, false)) {
                                 if (!free) {
                                     free = std::move(slotLock);
@@ -224,7 +229,11 @@ int main (int argc, char * * argv)
                     break;
                 }
 
+#if __APPLE__
+                futimes(bestSlotLock.get(), NULL);
+#else
                 futimens(bestSlotLock.get(), NULL);
+#endif
 
                 lock = -1;