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

Fixed remote issues

This commit is contained in:
Wouter den Breejen 2007-09-05 14:13:50 +00:00
parent 35e239af33
commit ed55982085
11 changed files with 57 additions and 56 deletions

View file

@ -509,7 +509,7 @@ static Expr prim_derivationStrict(EvalState & state, const ATermVector & args)
} }
} }
else if(key == "solidStateDependency"){ externalState = coerceToString(state, value, context, true); } else if(key == "solidStateDependency"){ externalState = coerceToString(state, value, context, true); }
else if(key == "shareType") { shareType = coerceToString(state, value, context, true); } else if(key == "shareType") { shareType = coerceToString(state, value, context, true); }
else if(key == "synchronization") { syncState = coerceToString(state, value, context, true); } else if(key == "synchronization") { syncState = coerceToString(state, value, context, true); }
else if(key == "disableState") { disableState = evalBool(state, value); } else if(key == "disableState") { disableState = evalBool(state, value); }

View file

@ -383,14 +383,12 @@ void Database::setString(const Transaction & txn, TableId table,
const string & key, const string & data) const string & key, const string & data)
{ {
checkInterrupt(); checkInterrupt();
printMsg(lvlError, format("SS: '%1%'") % data);
try { try {
Db * db = getDb(table); Db * db = getDb(table);
Dbt kt((void *) key.c_str(), key.length()); Dbt kt((void *) key.c_str(), key.length());
Dbt dt((void *) data.c_str(), data.length()); Dbt dt((void *) data.c_str(), data.length());
db->put(txn.txn, &kt, &dt, 0); db->put(txn.txn, &kt, &dt, 0);
} catch (DbException e) { rethrow(e); } } catch (DbException e) { rethrow(e); }
printMsg(lvlError, format("SETTEDS"));
} }

View file

@ -29,7 +29,9 @@ string thisSystem = "unset";
unsigned int maxSilentTime = 0; unsigned int maxSilentTime = 0;
static bool settingsRead = false; static bool settingsRead = false;
uid_t callingUID = 0; //A root user will not set this value, so the default uid is 0 uid_t callingUID = 0; //A root user will not set this value, so the default uid is 0
bool debugWorker = false; //TODO Still experimental ! this gives an store already open at the second call
bool singleThreaded = false; //TODO Gives an error: cannot start worker (environment already open) / waiting for process 7487: No child processes
bool sendOutput = true;
static std::map<string, Strings> settings; static std::map<string, Strings> settings;

View file

@ -96,7 +96,9 @@ string queryCallingUsername();
/* get the username based on the UID of the user currently runs the process */ /* get the username based on the UID of the user currently runs the process */
string queryCurrentUsername(); string queryCurrentUsername();
extern bool debugWorker; extern bool singleThreaded;
extern bool sendOutput;
} }

View file

@ -694,7 +694,7 @@ void setDeriver(const Transaction & txn, const Path & storePath, const Path & de
* into account. This function is used to update derivations that have only changed in their sub state * into account. This function is used to update derivations that have only changed in their sub state
* paths that need to be versioned for example. We assume newdrv is the newest. * paths that need to be versioned for example. We assume newdrv is the newest.
*/ */
PathSet mergeNewDerivationIntoListTxn(const Transaction txn, const Path & storepath, const Path & newdrv, const PathSet drvs, bool deleteDrvs) PathSet mergeNewDerivationIntoListTxn(const Transaction & txn, const Path & storepath, const Path & newdrv, const PathSet drvs, bool deleteDrvs)
{ {
PathSet newdrvs; PathSet newdrvs;
@ -744,11 +744,8 @@ void addStateDeriver(const Transaction & txn, const Path & storePath, const Path
for (PathSet::iterator i = updatedDerivers.begin(); i != updatedDerivers.end(); ++i) //Convert Paths to Strings for (PathSet::iterator i = updatedDerivers.begin(); i != updatedDerivers.end(); ++i) //Convert Paths to Strings
data.push_back(*i); data.push_back(*i);
for (Strings::iterator i = data.begin(); i != data.end(); ++i)
printMsg(lvlError, format("AA: %1%") % *i);
nixDB.setStrings(txn, dbDerivers, storePath, data); //update the derivers db. nixDB.setStrings(txn, dbDerivers, storePath, data); //update the derivers db.
printMsg(lvlError, format("%BB"));
nixDB.setString(txn, dbStateInfo, storePath, ""); //update the dbinfo db. (maybe TODO) nixDB.setString(txn, dbStateInfo, storePath, ""); //update the dbinfo db. (maybe TODO)
} }

View file

@ -40,7 +40,7 @@ void createSubStateDirsTxn(const Transaction & txn, const DerivationStateOutputD
//TODO //TODO
/* /*
if( ! DirectoryExist( ....... ) ){ if( ! DirectoryExists( ....... ) ){
} }
else else
printMsg(lvlTalkative, format("Statedir %1% already exists, so dont ........ ???? ") % ...); printMsg(lvlTalkative, format("Statedir %1% already exists, so dont ........ ???? ") % ...);

View file

@ -1177,16 +1177,14 @@ bool DirectoryExist(const string FileName)
} }
//TODO Does this work on windows? //TODO Does this work on windows?
bool IsSymlink(const string FileName) bool IsSymlink(const string FileName)
{ {
const char* FileName_C = FileName.c_str(); const char* FileName_C = FileName.c_str();
struct stat my_stat; struct stat my_stat;
if (lstat(FileName_C, &my_stat) != 0) return false; if (lstat(FileName_C, &my_stat) != 0) return false;
return (S_ISLNK(my_stat.st_mode) != 0); return (S_ISLNK(my_stat.st_mode) != 0);
} }
/* /*
string getCallingUserName() string getCallingUserName()
{ {
@ -1292,6 +1290,7 @@ void symlinkPath(const Path & fromExisting, const Path & toNew)
p_args.push_back(fromExisting); p_args.push_back(fromExisting);
p_args.push_back(toNew); p_args.push_back(toNew);
runProgram_AndPrintOutput("ln", true, p_args, "ln"); runProgram_AndPrintOutput("ln", true, p_args, "ln");
//printMsg(lvlError, format("ln -sf %1% %2%") % fromExisting % toNew); //printMsg(lvlError, format("ln -sf %1% %2%") % fromExisting % toNew);
} }
@ -1299,7 +1298,7 @@ void copyContents(const Path & from, const Path & to)
{ {
Strings p_args; Strings p_args;
p_args.push_back("-R"); p_args.push_back("-R");
p_args.push_back(from + "/"); //the / makes sure it copys the contents of the dir, not just the symlink p_args.push_back(from + "/"); //the / makes sure it copys the contents of the dir, not just the symlink
p_args.push_back(to); p_args.push_back(to);
runProgram_AndPrintOutput("cp", true, p_args, "cp"); runProgram_AndPrintOutput("cp", true, p_args, "cp");
} }

View file

@ -42,7 +42,7 @@ bool pathExists(const Path & path);
/* Return true if the given file exists. */ /* Return true if the given file exists. */
bool FileExist(const string FileName); bool FileExist(const string FileName);
/* Return true if the given dir exists. */ /* Return true if the given filename is a dir. */
bool DirectoryExist(const string FileName); bool DirectoryExist(const string FileName);
/* Return true if the given filename is a symlink. */ /* Return true if the given filename is a symlink. */

View file

@ -628,7 +628,6 @@ static void installDerivations(Globals & globals,
//1. If dir externalState exists, we move its data into the statePath //1. If dir externalState exists, we move its data into the statePath
//2. We ensure that the parent dir of externalState exists so we can create a symlink //2. We ensure that the parent dir of externalState exists so we can create a symlink
if(DirectoryExist(externalState)){ if(DirectoryExist(externalState)){
//We cannot copy into itself so we have to test that //We cannot copy into itself so we have to test that
if(IsSymlink(externalState)){ if(IsSymlink(externalState)){
Path read_statePath = readLink(externalState); Path read_statePath = readLink(externalState);
@ -641,15 +640,15 @@ static void installDerivations(Globals & globals,
} }
else else
copyContents(externalState, statePath); copyContents(externalState, statePath);
deletePath(externalState); deletePath(externalState);
} }
else{ else{
//Ensure parent dir //Ensure parent dir
string externalState_p = externalState; string externalState_p = externalState;
if(externalState_p[externalState_p.length() - 1] == '/') if(externalState_p[externalState_p.length() - 1] == '/')
externalState_p.erase(externalState_p.length(),1); externalState_p.erase(externalState_p.length(),1);
externalState_p = externalState_p.substr(0,externalState_p.find_last_of('/')); externalState_p = externalState_p.substr(0,externalState_p.find_last_of('/'));
ensureDirExists(externalState_p); ensureDirExists(externalState_p);
} }

View file

@ -486,11 +486,6 @@ void run(Strings args)
RevisionClosureTS timestamps; RevisionClosureTS timestamps;
bool b = store->queryStateRevisions("/nix/state/aacs4qpi9jzg4vmhj09d0ichframh22x-hellohardcodedstateworld-1.0-test", revisions, timestamps, 0); bool b = store->queryStateRevisions("/nix/state/aacs4qpi9jzg4vmhj09d0ichframh22x-hellohardcodedstateworld-1.0-test", revisions, timestamps, 0);
*/
store = openStore();
/*
PathSet sharedWith = getSharedWithPathSetRecTxn(noTxn, "/nix/state/1kjxymaxf0i6qp5k8ggacc06bzbi4b82-hellohardcodedstateworld-1.0-test"); PathSet sharedWith = getSharedWithPathSetRecTxn(noTxn, "/nix/state/1kjxymaxf0i6qp5k8ggacc06bzbi4b82-hellohardcodedstateworld-1.0-test");
for (PathSet::const_iterator j = sharedWith.begin(); j != sharedWith.end(); ++j) for (PathSet::const_iterator j = sharedWith.begin(); j != sharedWith.end(); ++j)
printMsg(lvlError, format("RootSP SW '%1%'") % *j); printMsg(lvlError, format("RootSP SW '%1%'") % *j);

View file

@ -28,6 +28,7 @@ using namespace nix;
static FdSource from(STDIN_FILENO); static FdSource from(STDIN_FILENO);
static FdSink to(STDOUT_FILENO); static FdSink to(STDOUT_FILENO);
bool storeOpen = false;
bool canSendStderr; bool canSendStderr;
pid_t myPid; pid_t myPid;
@ -43,7 +44,7 @@ static void tunnelStderr(const unsigned char * buf, size_t count)
process handling the connection. Otherwise we could screw up process handling the connection. Otherwise we could screw up
the protocol. It's up to the parent to redirect stderr and the protocol. It's up to the parent to redirect stderr and
send it to the client somehow (e.g., as in build.cc). */ send it to the client somehow (e.g., as in build.cc). */
if (canSendStderr && myPid == getpid() && (!debugWorker)) { //TODO debugWorker commit if ((canSendStderr && myPid == getpid()) && (sendOutput)) {
try { try {
writeInt(STDERR_NEXT, to); writeInt(STDERR_NEXT, to);
writeString(string((char *) buf, count), to); writeString(string((char *) buf, count), to);
@ -54,7 +55,6 @@ static void tunnelStderr(const unsigned char * buf, size_t count)
throw; throw;
} }
} else{ } else{
//printMsg(lvlInfo, format("nix-worker: debug mode"));
writeFull(STDERR_FILENO, buf, count); writeFull(STDERR_FILENO, buf, count);
} }
} }
@ -232,7 +232,9 @@ static void performOp(Source & from, Sink & to, unsigned int op)
#if 0 #if 0
case wopQuit: { case wopQuit: {
/* Close the database. */ /* Close the database. */
store.reset((StoreAPI *) 0); if(!singleThreaded){
store.reset((StoreAPI *) 0);
}
writeInt(1, to); writeInt(1, to);
break; break;
} }
@ -636,7 +638,16 @@ static void processConnection()
throw Error("if you run `nix-worker' as root, then you MUST set `build-users-group'!"); throw Error("if you run `nix-worker' as root, then you MUST set `build-users-group'!");
/* Open the store. */ /* Open the store. */
store = boost::shared_ptr<StoreAPI>(new LocalStore(true)); if(singleThreaded){ //only open once
if(!storeOpen){
printMsg(lvlError, format("Opening store"));
storeOpen = true;
store = boost::shared_ptr<StoreAPI>(new LocalStore(true));
}
}
else{
store = boost::shared_ptr<StoreAPI>(new LocalStore(true));
}
stopWork(); stopWork();
@ -745,8 +756,8 @@ static void daemonLoop()
/* Important: the server process *cannot* open the /* Important: the server process *cannot* open the
Berkeley DB environment, because it doesn't like forks Berkeley DB environment, because it doesn't like forks
very much. */ very much. */
if(!debugWorker) if(!singleThreaded)
assert(!store); assert(!store);
/* Accept a connection. */ /* Accept a connection. */
struct sockaddr_un remoteAddr; struct sockaddr_un remoteAddr;
@ -766,9 +777,29 @@ static void daemonLoop()
printMsg(lvlInfo, format("accepted connection '%1%'") printMsg(lvlInfo, format("accepted connection '%1%'")
% remote); % remote);
if(!debugWorker)
{
if(singleThreaded)
{
printMsg(lvlInfo, format("Nix-worker: debug mode: we can only process 1 job at the time"));
/* We RESET the user id of the caller cause we have no fork */
setCallingUID(caller_uid, true);
printMsg(lvlInfo, format("Debug connection '%1%' created for userid: '%2%' with username: '%3%'")
% remote % queryCallingUID() % queryCallingUsername());
/* Background the worker. */
//if (setsid() == -1)
// throw SysError(format("creating a new session"));
/* Restore normal handling of SIGCHLD. */
//setSigChldAction(false);
/* Handle the connection. */
from.fd = remote;
to.fd = remote;
processConnection();
}
else
{
/* Fork a child to handle the connection. */ /* Fork a child to handle the connection. */
pid_t child; pid_t child;
child = fork(); child = fork();
@ -804,28 +835,6 @@ static void daemonLoop()
exit(0); exit(0);
} }
} }
else
{
printMsg(lvlInfo, format("Nix-worker: debug mode: we can only process 1 job at the time"));
/* We RESET the user id of the caller cause we have no fork */
setCallingUID(caller_uid, true);
printMsg(lvlInfo, format("Debug connection '%1%' created for userid: '%2%' with username: '%3%'")
% remote % queryCallingUID() % queryCallingUsername());
/* Background the worker. */
//if (setsid() == -1)
// throw SysError(format("creating a new session"));
/* Restore normal handling of SIGCHLD. */
//setSigChldAction(false);
/* Handle the connection. */
from.fd = remote;
to.fd = remote;
processConnection();
}
} catch (Interrupted & e) { } catch (Interrupted & e) {
throw; throw;