From b1004f40f7e4dd02feec2d0cb26bd6c95dd66dde Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 30 Dec 2011 14:47:14 +0000 Subject: * Reject a build if there is a cycle among the outputs. This is necessary because existing code assumes that the references graph is acyclic. --- src/libstore/local-store.cc | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/libstore/local-store.cc') diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index 29817df9d6e8..771776f6a2c7 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -966,12 +966,14 @@ void LocalStore::registerValidPaths(const ValidPathInfos & infos) while (1) { try { SQLiteTxn txn(db); + PathSet paths; foreach (ValidPathInfos::const_iterator, i, infos) { assert(i->hash.type == htSHA256); /* !!! Maybe the registration info should be updated if the path is already valid. */ if (!isValidPath(i->path)) addValidPath(*i); + paths.insert(i->path); } foreach (ValidPathInfos::const_iterator, i, infos) { @@ -980,6 +982,12 @@ void LocalStore::registerValidPaths(const ValidPathInfos & infos) addReference(referrer, queryValidPathId(*j)); } + /* Do a topological sort of the paths. This will throw an + error if a cycle is detected and roll back the + transaction. Cycles can only occur when a derivation + has multiple outputs. */ + topoSortPaths(*this, paths); + txn.commit(); break; } catch (SQLiteBusy & e) { -- cgit 1.4.1