* Move root finding from nix-collect-garbage' to nix-store --gc'.

This was necessary becase root finding must be done after
  acquisition of the global GC lock.

  This makes `nix-collect-garbage' obsolete; it is now just a wrapper
  around `nix-store --gc'.

* Automatically remove stale GC roots (i.e., indirect GC roots that
  point to non-existent paths).
This commit is contained in:
Eelco Dolstra 2005-02-01 15:05:32 +00:00
parent 630ae0c9d7
commit 65b6c8ab4c
4 changed files with 75 additions and 111 deletions

View file

@ -5,15 +5,21 @@
/* Garbage collector operation. */
typedef enum { gcReturnLive, gcReturnDead, gcDeleteDead } GCAction;
typedef enum {
gcReturnRoots,
gcReturnLive,
gcReturnDead,
gcDeleteDead,
} GCAction;
/* If `action' is set to `soReturnLive', return the set of paths
reachable from (i.e. in the closure of) the specified roots. If
`action' is `soReturnDead', return the set of paths not reachable
from the roots. If `action' is `soDeleteDead', actually delete the
latter set. */
void collectGarbage(const PathSet & roots, GCAction action,
PathSet & result);
/* If `action' is set to `gcReturnRoots', find and return the set of
roots for the garbage collector. These are the store paths
symlinked to in the `gcroots' directory. If `action' is
`gcReturnLive', return the set of paths reachable from (i.e. in the
closure of) the roots. If `action' is `gcReturnDead', return the
set of paths not reachable from the roots. If `action' is
`gcDeleteDead', actually delete the latter set. */
void collectGarbage(GCAction action, PathSet & result);
/* Register a temporary GC root. This root will automatically
disappear when this process exits. WARNING: this function should