[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
113/118: Clean up temp roots in a more C++ way
From: |
Ludovic Courtès |
Subject: |
113/118: Clean up temp roots in a more C++ way |
Date: |
Tue, 19 May 2015 14:46:05 +0000 |
civodul pushed a commit to branch nix
in repository guix.
commit f160a30d5612506de41a8206a57eccee1cd85fb7
Author: Eelco Dolstra <address@hidden>
Date: Wed Nov 19 17:07:29 2014 +0100
Clean up temp roots in a more C++ way
---
nix/libstore/gc.cc | 26 --------------------------
nix/libstore/local-store.cc | 9 +++++++++
nix/libstore/local-store.hh | 4 ++++
3 files changed, 13 insertions(+), 26 deletions(-)
diff --git a/nix/libstore/gc.cc b/nix/libstore/gc.cc
index 2a53b54..e019d93 100644
--- a/nix/libstore/gc.cc
+++ b/nix/libstore/gc.cc
@@ -145,11 +145,6 @@ Path addPermRoot(StoreAPI & store, const Path & _storePath,
}
-/* The file to which we write our temporary roots. */
-static Path fnTempRoots;
-static AutoCloseFD fdTempRoots;
-
-
void LocalStore::addTempRoot(const Path & path)
{
/* Create the temporary roots file for this process. */
@@ -204,27 +199,6 @@ void LocalStore::addTempRoot(const Path & path)
}
-void removeTempRoots()
-{
- if (fdTempRoots != -1) {
- fdTempRoots.close();
- unlink(fnTempRoots.c_str());
- }
-}
-
-
-/* Automatically clean up the temporary roots file when we exit. */
-struct RemoveTempRoots
-{
- ~RemoveTempRoots()
- {
- removeTempRoots();
- }
-};
-
-static RemoveTempRoots autoRemoveTempRoots __attribute__((unused));
-
-
typedef std::shared_ptr<AutoCloseFD> FDPtr;
typedef list<FDPtr> FDs;
diff --git a/nix/libstore/local-store.cc b/nix/libstore/local-store.cc
index 2f5c0e1..e3de33b 100644
--- a/nix/libstore/local-store.cc
+++ b/nix/libstore/local-store.cc
@@ -363,6 +363,15 @@ LocalStore::~LocalStore()
} catch (...) {
ignoreException();
}
+
+ try {
+ if (fdTempRoots != -1) {
+ fdTempRoots.close();
+ unlink(fnTempRoots.c_str());
+ }
+ } catch (...) {
+ ignoreException();
+ }
}
diff --git a/nix/libstore/local-store.hh b/nix/libstore/local-store.hh
index dccdba5..e0aabdb 100644
--- a/nix/libstore/local-store.hh
+++ b/nix/libstore/local-store.hh
@@ -244,6 +244,10 @@ private:
bool didSetSubstituterEnv;
+ /* The file to which we write our temporary roots. */
+ Path fnTempRoots;
+ AutoCloseFD fdTempRoots;
+
int getSchema();
void openDB(bool create);
- 81/118: findRoots(): Prevent a call to lstat(), (continued)
- 81/118: findRoots(): Prevent a call to lstat(), Ludovic Courtès, 2015/05/19
- 101/118: On Linux, disable address space randomization, Ludovic Courtès, 2015/05/19
- 91/118: Use regular file GC roots if possible, Ludovic Courtès, 2015/05/19
- 102/118: Remove bogus comment, Ludovic Courtès, 2015/05/19
- 80/118: Make readDirectory() return inode / file type, Ludovic Courtès, 2015/05/19
- 94/118: Doh, Ludovic Courtès, 2015/05/19
- 96/118: fix disappearing bash arguments, Ludovic Courtès, 2015/05/19
- 104/118: createDirs(): Handle ‘path’ being a symlink, Ludovic Courtès, 2015/05/19
- 103/118: nix-daemon: Close unnecessary fd, Ludovic Courtès, 2015/05/19
- 97/118: Introduce allowedRequisites feature, Ludovic Courtès, 2015/05/19
- 113/118: Clean up temp roots in a more C++ way,
Ludovic Courtès <=
- 105/118: Remove some duplicate code, Ludovic Courtès, 2015/05/19
- 108/118: Improve error message if the daemon worker fails to start, Ludovic Courtès, 2015/05/19
- 100/118: Settings: Add bool get(), Ludovic Courtès, 2015/05/19
- 106/118: Improved error message when encountering unsupported file types, Ludovic Courtès, 2015/05/19
- 114/118: nix-daemon: Call exit(), not _exit(), Ludovic Courtès, 2015/05/19
- 99/118: Add an 'optimiseStore' remote procedure call., Ludovic Courtès, 2015/05/19
- 107/118: Fix build on gcc < 4.7, Ludovic Courtès, 2015/05/19
- 98/118: Add disallowedReferences / disallowedRequisites, Ludovic Courtès, 2015/05/19
- 110/118: Make ~DerivationGoal more reliable, Ludovic Courtès, 2015/05/19
- 111/118: Don't use ADDR_LIMIT_3GB, Ludovic Courtès, 2015/05/19