about summary refs log tree commit diff
path: root/src/libstore/remote-store.cc
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2016-07-11T19·44-0400
committerShea Levy <shea@shealevy.com>2016-07-11T19·44-0400
commitcb5e7254b66a06b78a5659551a6f28fc67e52267 (patch)
treee367ff5e386fc16247034da60cf30aff61ebaea4 /src/libstore/remote-store.cc
parent8a41792d431d6578836fde04d1742dbba878f979 (diff)
Modernize AutoCloseFD
Diffstat (limited to 'src/libstore/remote-store.cc')
-rw-r--r--src/libstore/remote-store.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc
index 50ad409a927e..ab05c3844289 100644
--- a/src/libstore/remote-store.cc
+++ b/src/libstore/remote-store.cc
@@ -66,9 +66,9 @@ ref<RemoteStore::Connection> RemoteStore::openConnection()
         | SOCK_CLOEXEC
         #endif
         , 0);
-    if (conn->fd == -1)
+    if (!conn->fd)
         throw SysError("cannot create Unix domain socket");
-    closeOnExec(conn->fd);
+    closeOnExec(conn->fd.get());
 
     string socketPath = settings.nixDaemonSocketFile;
 
@@ -78,11 +78,11 @@ ref<RemoteStore::Connection> RemoteStore::openConnection()
         throw Error(format("socket path ‘%1%’ is too long") % socketPath);
     strcpy(addr.sun_path, socketPath.c_str());
 
-    if (connect(conn->fd, (struct sockaddr *) &addr, sizeof(addr)) == -1)
+    if (connect(conn->fd.get(), (struct sockaddr *) &addr, sizeof(addr)) == -1)
         throw SysError(format("cannot connect to daemon at ‘%1%’") % socketPath);
 
-    conn->from.fd = conn->fd;
-    conn->to.fd = conn->fd;
+    conn->from.fd = conn->fd.get();
+    conn->to.fd = conn->fd.get();
 
     /* Send the magic greeting, check for the reply. */
     try {
@@ -531,7 +531,7 @@ RemoteStore::Connection::~Connection()
 {
     try {
         to.flush();
-        fd.close();
+        fd = -1;
     } catch (...) {
         ignoreException();
     }