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:
parent
35e239af33
commit
ed55982085
11 changed files with 57 additions and 56 deletions
|
|
@ -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 == "synchronization") { syncState = coerceToString(state, value, context, true); }
|
||||
else if(key == "disableState") { disableState = evalBool(state, value); }
|
||||
|
|
|
|||
|
|
@ -383,14 +383,12 @@ void Database::setString(const Transaction & txn, TableId table,
|
|||
const string & key, const string & data)
|
||||
{
|
||||
checkInterrupt();
|
||||
printMsg(lvlError, format("SS: '%1%'") % data);
|
||||
try {
|
||||
Db * db = getDb(table);
|
||||
Dbt kt((void *) key.c_str(), key.length());
|
||||
Dbt dt((void *) data.c_str(), data.length());
|
||||
db->put(txn.txn, &kt, &dt, 0);
|
||||
} catch (DbException e) { rethrow(e); }
|
||||
printMsg(lvlError, format("SETTEDS"));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,9 @@ string thisSystem = "unset";
|
|||
unsigned int maxSilentTime = 0;
|
||||
static bool settingsRead = false;
|
||||
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;
|
||||
|
||||
|
|
|
|||
|
|
@ -96,7 +96,9 @@ string queryCallingUsername();
|
|||
/* get the username based on the UID of the user currently runs the process */
|
||||
string queryCurrentUsername();
|
||||
|
||||
extern bool debugWorker;
|
||||
extern bool singleThreaded;
|
||||
extern bool sendOutput;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
* 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;
|
||||
|
||||
|
|
@ -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
|
||||
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.
|
||||
|
||||
printMsg(lvlError, format("%BB"));
|
||||
nixDB.setString(txn, dbStateInfo, storePath, ""); //update the dbinfo db. (maybe TODO)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ void createSubStateDirsTxn(const Transaction & txn, const DerivationStateOutputD
|
|||
//TODO
|
||||
|
||||
/*
|
||||
if( ! DirectoryExist( ....... ) ){
|
||||
if( ! DirectoryExists( ....... ) ){
|
||||
}
|
||||
else
|
||||
printMsg(lvlTalkative, format("Statedir %1% already exists, so dont ........ ???? ") % ...);
|
||||
|
|
|
|||
|
|
@ -1177,16 +1177,14 @@ bool DirectoryExist(const string FileName)
|
|||
}
|
||||
|
||||
//TODO Does this work on windows?
|
||||
|
||||
bool IsSymlink(const string FileName)
|
||||
{
|
||||
const char* FileName_C = FileName.c_str();
|
||||
struct stat my_stat;
|
||||
if (lstat(FileName_C, &my_stat) != 0) return false;
|
||||
return (S_ISLNK(my_stat.st_mode) != 0);
|
||||
struct stat my_stat;
|
||||
if (lstat(FileName_C, &my_stat) != 0) return false;
|
||||
return (S_ISLNK(my_stat.st_mode) != 0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
string getCallingUserName()
|
||||
{
|
||||
|
|
@ -1292,6 +1290,7 @@ void symlinkPath(const Path & fromExisting, const Path & toNew)
|
|||
p_args.push_back(fromExisting);
|
||||
p_args.push_back(toNew);
|
||||
runProgram_AndPrintOutput("ln", true, p_args, "ln");
|
||||
|
||||
//printMsg(lvlError, format("ln -sf %1% %2%") % fromExisting % toNew);
|
||||
}
|
||||
|
||||
|
|
@ -1299,7 +1298,7 @@ void copyContents(const Path & from, const Path & to)
|
|||
{
|
||||
Strings p_args;
|
||||
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);
|
||||
runProgram_AndPrintOutput("cp", true, p_args, "cp");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ bool pathExists(const Path & path);
|
|||
/* Return true if the given file exists. */
|
||||
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);
|
||||
|
||||
/* Return true if the given filename is a symlink. */
|
||||
|
|
|
|||
|
|
@ -628,7 +628,6 @@ static void installDerivations(Globals & globals,
|
|||
//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
|
||||
if(DirectoryExist(externalState)){
|
||||
|
||||
//We cannot copy into itself so we have to test that
|
||||
if(IsSymlink(externalState)){
|
||||
Path read_statePath = readLink(externalState);
|
||||
|
|
@ -648,7 +647,7 @@ static void installDerivations(Globals & globals,
|
|||
//Ensure parent dir
|
||||
string externalState_p = externalState;
|
||||
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('/'));
|
||||
ensureDirExists(externalState_p);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -486,11 +486,6 @@ void run(Strings args)
|
|||
RevisionClosureTS timestamps;
|
||||
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");
|
||||
for (PathSet::const_iterator j = sharedWith.begin(); j != sharedWith.end(); ++j)
|
||||
printMsg(lvlError, format("RootSP SW '%1%'") % *j);
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ using namespace nix;
|
|||
static FdSource from(STDIN_FILENO);
|
||||
static FdSink to(STDOUT_FILENO);
|
||||
|
||||
bool storeOpen = false;
|
||||
bool canSendStderr;
|
||||
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
|
||||
the protocol. It's up to the parent to redirect stderr and
|
||||
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 {
|
||||
writeInt(STDERR_NEXT, to);
|
||||
writeString(string((char *) buf, count), to);
|
||||
|
|
@ -54,7 +55,6 @@ static void tunnelStderr(const unsigned char * buf, size_t count)
|
|||
throw;
|
||||
}
|
||||
} else{
|
||||
//printMsg(lvlInfo, format("nix-worker: debug mode"));
|
||||
writeFull(STDERR_FILENO, buf, count);
|
||||
}
|
||||
}
|
||||
|
|
@ -232,7 +232,9 @@ static void performOp(Source & from, Sink & to, unsigned int op)
|
|||
#if 0
|
||||
case wopQuit: {
|
||||
/* Close the database. */
|
||||
store.reset((StoreAPI *) 0);
|
||||
if(!singleThreaded){
|
||||
store.reset((StoreAPI *) 0);
|
||||
}
|
||||
writeInt(1, to);
|
||||
break;
|
||||
}
|
||||
|
|
@ -636,7 +638,16 @@ static void processConnection()
|
|||
throw Error("if you run `nix-worker' as root, then you MUST set `build-users-group'!");
|
||||
|
||||
/* 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();
|
||||
|
||||
|
|
@ -745,8 +756,8 @@ static void daemonLoop()
|
|||
/* Important: the server process *cannot* open the
|
||||
Berkeley DB environment, because it doesn't like forks
|
||||
very much. */
|
||||
if(!debugWorker)
|
||||
assert(!store);
|
||||
if(!singleThreaded)
|
||||
assert(!store);
|
||||
|
||||
/* Accept a connection. */
|
||||
struct sockaddr_un remoteAddr;
|
||||
|
|
@ -766,9 +777,29 @@ static void daemonLoop()
|
|||
printMsg(lvlInfo, format("accepted connection '%1%'")
|
||||
% 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. */
|
||||
pid_t child;
|
||||
child = fork();
|
||||
|
|
@ -804,28 +835,6 @@ static void daemonLoop()
|
|||
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) {
|
||||
throw;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue