1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-26 20:20:58 +01:00

Fixed a lot of remote store issues. But there is still a bug with 32bit unsigned integers: 'implementation cannot deal with > 32-bit integers'

This commit is contained in:
Wouter den Breejen 2007-08-28 15:22:27 +00:00
parent 2e7539bd27
commit 627afcc1aa
16 changed files with 144 additions and 54 deletions

View file

@ -1830,7 +1830,7 @@ void DerivationGoal::computeClosure()
}
txn.commit();
/* It is now safe to delete the lock files, since all future
lockers will see that the output paths are valid; they will not
create new lock files with the same names as the old (unlinked)

View file

@ -71,7 +71,7 @@ Transaction::~Transaction()
void Transaction::begin(Database & db)
{
assert(txn == 0);
db.requireEnv();
db.requireEnv("begin transaction");
try {
db.env->txn_begin(0, &txn, 0);
} catch (DbException e) { rethrow(e); }
@ -110,11 +110,11 @@ void Transaction::moveTo(Transaction & t)
}
void Database::requireEnv()
void Database::requireEnv(string debug)
{
checkInterrupt();
if (!env) throw Error("database environment is not open "
"(maybe you don't have sufficient permission?)");
if (!env) throw Error(format("database environment is not open while trying '%1%'"
"(maybe you don't have sufficient permission?)") % debug);
}
@ -300,7 +300,7 @@ void Database::close()
TableId Database::openTable(const string & tableName, bool sorted)
{
requireEnv();
requireEnv(tableName);
TableId table = nextId++;
try {

View file

@ -54,7 +54,7 @@ private:
TableId nextId;
std::map<TableId, Db *> tables;
void requireEnv();
void requireEnv(string debug);
Db * getDb(TableId table);

View file

@ -28,8 +28,8 @@ bool readOnlyMode = false;
string thisSystem = "unset";
unsigned int maxSilentTime = 0;
static bool settingsRead = false;
uid_t callingUID = 0;
bool debugWorker = true;
uid_t callingUID = 0; //A root user will not set this value, so the default uid is 0
bool debugWorker = false; //TODO still experimental
static std::map<string, Strings> settings;
@ -132,16 +132,23 @@ void setCallingUID(uid_t uid, bool reset)
callingUID = uid;
}
string queryCallingUsername()
string uidToUsername(uid_t uid)
{
uid_t uid = queryCallingUID();
passwd *pwd = getpwuid(uid);
char *pw_name = pwd->pw_name;
return (string)pw_name;
}
string queryCallingUsername()
{
uid_t uid = queryCallingUID();
return uidToUsername(uid);
}
string queryCurrentUsername()
{
return uidToUsername(geteuid());
}
}

View file

@ -86,9 +86,16 @@ extern uid_t callingUID;
/* get/set the UID of the user that calls the nix-worker daemon */
uid_t queryCallingUID();
void setCallingUID(uid_t uid, bool reset = false);
/* Convert a uid to a username: Watch it! this segfaults when given a wrong uid !! */
string uidToUsername(uid_t uid);
/* get the username based on the UID of the user that calls the nix-worker daemon */
string queryCallingUsername();
/* get the username based on the UID of the user currently runs the process */
string queryCurrentUsername();
extern bool debugWorker;
}

View file

@ -9,16 +9,29 @@
namespace nix {
Derivation derivationFromPathTxn(const Transaction & txn, const Path & drvPath)
Derivation derivationFromPathPrivate(const bool dotxn, const Transaction & txn, const Path & drvPath)
{
assertStorePath(drvPath);
ensurePathTxn(txn, drvPath);
if(dotxn)
ensurePathTxn(txn, drvPath);
else
store->ensurePath(drvPath);
ATerm t = ATreadFromNamedFile(drvPath.c_str());
if (!t)
throw Error(format("cannot read aterm from `%1%'") % drvPath);
return parseDerivation(t);
}
//Wrappers
Derivation derivationFromPath(const Path & drvPath)
{
return derivationFromPathPrivate(false, noTxn, drvPath);
}
Derivation derivationFromPathTxn(const Transaction & txn, const Path & drvPath)
{
return derivationFromPathPrivate(true, txn, drvPath);
}
void computeFSClosure(const Path & path, PathSet & paths, const bool & withComponents, const bool & withState, const int revision, bool flipDirection)
{
computeFSClosureTxn(noTxn, path, paths, withComponents, withState, revision, flipDirection);

View file

@ -12,6 +12,9 @@ namespace nix {
ensurePath(). */
Derivation derivationFromPathTxn(const Transaction & txn, const Path & drvPath);
/* Same as above, but wihouth a txn now. This function can be called from the user side */
Derivation derivationFromPath(const Path & drvPath);
/* Place in `paths' the set of all store paths in the file system
closure of `storePath'; that is, all paths than can be directly or
indirectly reached from it. `paths' is not cleared. If

View file

@ -274,9 +274,7 @@ Path RemoteStore::addToStore(const Path & _srcPath, bool fixed,
writeString(hashAlgo, to);
dumpPath(srcPath, to, filter);
processStderr();
printMsg(lvlInfo, format("REMOTESTORE: ADD TO STORE REMOTE 1"));
Path path = readStorePath(from);
printMsg(lvlInfo, format("REMOTESTORE: ADD TO STORE REMOTE 2"));
return path;
}
@ -396,6 +394,14 @@ void RemoteStore::collectGarbage(GCAction action, const PathSet & pathsToDelete,
bytesFreed = (((unsigned long long) hi) << 32) | lo;
}
Path RemoteStore::queryDeriver(const Path & path)
{
writeInt(wopQueryDeriver, to);
writeString(path, to);
processStderr();
return readStorePath(from);
}
PathSet RemoteStore::queryDerivers(const Path & storePath, const string & identifier, const string & user)
{
writeInt(wopQueryDerivers, to);
@ -498,13 +504,6 @@ void RemoteStore::scanAndUpdateAllReferences(const Path & statePath, const bool
readInt(from);
}
Path RemoteStore::queryDeriver(const Path & path)
{
writeInt(wopQueryDeriver, to);
writeString(path, to);
processStderr();
return readStorePath(from);
}
PathSet RemoteStore::toNonSharedPathSet(const PathSet & statePaths)
{

View file

@ -24,7 +24,7 @@ typedef enum {
wopQueryStateReferrers,
wopAddToStore,
wopAddTextToStore,
wopBuildDerivations,
wopBuildDerivations, //TODO HANGS SOMETIMES !!!!!
wopEnsurePath,
wopAddTempRoot,
wopAddIndirectRoot,