Whitespace

This commit is contained in:
Eelco Dolstra 2012-07-30 17:13:25 -04:00
parent 9cd63d2244
commit d50d7a2874
4 changed files with 61 additions and 61 deletions

View File

@ -46,7 +46,7 @@ Path makeRootName(const Path & gcRoot, int & counter)
void printGCWarning()
{
static bool haveWarned = false;
warnOnce(haveWarned,
warnOnce(haveWarned,
"you did not specify `--add-root'; "
"the result might be removed by the garbage collector");
}
@ -98,7 +98,7 @@ static bool showTrace = false;
static void initAndRun(int argc, char * * argv)
{
setDefaultsFromEnvironment();
/* Catch SIGINT. */
struct sigaction act;
act.sa_handler = sigintHandler;
@ -137,7 +137,7 @@ static void initAndRun(int argc, char * * argv)
Strings args, remaining;
while (argc--) args.push_back(*argv++);
args.erase(args.begin());
/* Expand compound dash options (i.e., `-qlf' -> `-q -l -f'), and
ignore options for the ATerm library. */
for (Strings::iterator i = args.begin(); i != args.end(); ++i) {
@ -210,7 +210,7 @@ static void initAndRun(int argc, char * * argv)
verbosityDelta += queryIntSetting("verbosity", lvlInfo);
verbosity = (Verbosity) (verbosityDelta < 0 ? 0 : verbosityDelta);
run(remaining);
/* Close the Nix database. */
@ -228,7 +228,7 @@ static void setuidInit()
uid_t nixUid = geteuid();
gid_t nixGid = getegid();
setuidCleanup();
/* Don't trust the current directory. */
@ -294,7 +294,7 @@ int main(int argc, char * * argv)
right away. */
if (argc == 0) abort();
setuidInit();
/* Turn on buffering for cerr. */
#if HAVE_PUBSETBUF
std::cerr.rdbuf()->pubsetbuf(buf, sizeof(buf));
@ -323,7 +323,7 @@ int main(int argc, char * * argv)
throw;
}
} catch (UsageError & e) {
printMsg(lvlError,
printMsg(lvlError,
format(
"error: %1%\n"
"Try `%2% --help' for more information.")

View File

@ -60,7 +60,7 @@ void RemoteStore::openConnection(bool reserveSpace)
else
throw Error(format("invalid setting for NIX_REMOTE, `%1%'")
% remoteMode);
from.fd = fdSocket;
to.fd = fdSocket;
@ -103,15 +103,15 @@ void RemoteStore::forkSlave()
worker = nixBinDir + "/nix-worker";
child = fork();
switch (child) {
case -1:
throw SysError("unable to fork");
case 0:
try { /* child */
if (dup2(fdChild, STDOUT_FILENO) == -1)
throw SysError("dupping write side");
@ -124,7 +124,7 @@ void RemoteStore::forkSlave()
execlp(worker.c_str(), worker.c_str(), "--slave", NULL);
throw SysError(format("executing `%1%'") % worker);
} catch (std::exception & e) {
std::cerr << format("child error: %1%\n") % e.what();
}
@ -150,16 +150,16 @@ void RemoteStore::connectToDaemon()
applications... */
AutoCloseFD fdPrevDir = open(".", O_RDONLY);
if (fdPrevDir == -1) throw SysError("couldn't open current directory");
chdir(dirOf(socketPath).c_str());
chdir(dirOf(socketPath).c_str());
Path socketPathRel = "./" + baseNameOf(socketPath);
struct sockaddr_un addr;
addr.sun_family = AF_UNIX;
if (socketPathRel.size() >= sizeof(addr.sun_path))
throw Error(format("socket path `%1%' is too long") % socketPathRel);
using namespace std;
strcpy(addr.sun_path, socketPathRel.c_str());
if (connect(fdSocket, (struct sockaddr *) &addr, sizeof(addr)) == -1)
throw SysError(format("cannot connect to daemon at `%1%'") % socketPath);
@ -199,9 +199,9 @@ void RemoteStore::setOptions()
}
if (GET_PROTOCOL_MINOR(daemonVersion) >= 6)
writeInt(buildCores, to);
if (GET_PROTOCOL_MINOR(daemonVersion) >= 10)
if (GET_PROTOCOL_MINOR(daemonVersion) >= 10)
writeInt(queryBoolSetting("build-use-substitutes", true), to);
processStderr();
}
@ -270,11 +270,11 @@ void RemoteStore::querySubstitutablePathInfos(const PathSet & paths,
if (paths.empty()) return;
openConnection();
if (GET_PROTOCOL_MINOR(daemonVersion) < 3) return;
if (GET_PROTOCOL_MINOR(daemonVersion) < 12) {
foreach (PathSet::const_iterator, i, paths) {
SubstitutablePathInfo info;
writeInt(wopQuerySubstitutablePathInfo, to);
@ -289,9 +289,9 @@ void RemoteStore::querySubstitutablePathInfos(const PathSet & paths,
info.narSize = GET_PROTOCOL_MINOR(daemonVersion) >= 7 ? readLongLong(from) : 0;
infos[*i] = info;
}
} else {
writeInt(wopQuerySubstitutablePathInfos, to);
writeStrings(paths, to);
processStderr();
@ -305,7 +305,7 @@ void RemoteStore::querySubstitutablePathInfos(const PathSet & paths,
info.downloadSize = readLongLong(from);
info.narSize = readLongLong(from);
}
}
}
@ -411,7 +411,7 @@ Path RemoteStore::addToStore(const Path & _srcPath,
bool recursive, HashType hashAlgo, PathFilter & filter)
{
openConnection();
Path srcPath(absPath(_srcPath));
writeInt(wopAddToStore, to);
@ -434,7 +434,7 @@ Path RemoteStore::addTextToStore(const string & name, const string & s,
writeString(name, to);
writeString(s, to);
writeStrings(references, to);
processStderr();
return readStorePath(from);
}
@ -531,7 +531,7 @@ Roots RemoteStore::findRoots()
void RemoteStore::collectGarbage(const GCOptions & options, GCResults & results)
{
openConnection(false);
writeInt(wopCollectGarbage, to);
writeInt(options.action, to);
writeStrings(options.pathsToDelete, to);
@ -543,9 +543,9 @@ void RemoteStore::collectGarbage(const GCOptions & options, GCResults & results)
writeInt(0, to);
writeInt(0, to);
}
processStderr();
results.paths = readStrings<PathSet>(from);
results.bytesFreed = readLongLong(from);
results.blocksFreed = readLongLong(from);

View File

@ -63,5 +63,5 @@ typedef enum {
Path readStorePath(Source & from);
template<class T> T readStorePaths(Source & from);
}

View File

@ -95,7 +95,7 @@ static bool isFarSideClosed(int socket)
throw Error("EOF expected (protocol error?)");
else if (rd == -1 && errno != ECONNRESET)
throw SysError("expected connection reset or EOF");
return true;
}
@ -185,7 +185,7 @@ static void stopWork(bool success = true, const string & msg = "", unsigned int
we're either sending or receiving from the client, so we'll be
notified of client death anyway. */
setSigPollAction(false);
canSendStderr = false;
if (success)
@ -220,7 +220,7 @@ struct TunnelSource : BufferedSource
so we have to disable the SIGPOLL handler. */
setSigPollAction(false);
canSendStderr = false;
writeInt(STDERR_READ, to);
writeInt(len, to);
to.flush();
@ -279,7 +279,7 @@ static void performOp(unsigned int clientVersion,
{
switch (op) {
#if 0
#if 0
case wopQuit: {
/* Close the database. */
store.reset((StoreAPI *) 0);
@ -323,7 +323,7 @@ static void performOp(unsigned int clientVersion,
writeStrings(res, to);
break;
}
case wopQueryPathHash: {
Path path = readStorePath(from);
startWork();
@ -391,7 +391,7 @@ static void performOp(unsigned int clientVersion,
SavingSourceAdapter savedNAR(from);
RetrieveRegularNARSink savedRegular;
if (recursive) {
/* Get the entire NAR dump from the client and save it to
a string so that we can pass it to
@ -400,13 +400,13 @@ static void performOp(unsigned int clientVersion,
parseDump(sink, savedNAR);
} else
parseDump(savedRegular, from);
startWork();
if (!savedRegular.regular) throw Error("regular file expected");
Path path = dynamic_cast<LocalStore *>(store.get())
->addToStoreFromDump(recursive ? savedNAR.s : savedRegular.s, baseName, recursive, hashAlgo);
stopWork();
writeString(path, to);
break;
}
@ -512,17 +512,17 @@ static void performOp(unsigned int clientVersion,
}
GCResults results;
startWork();
if (options.ignoreLiveness)
throw Error("you are not allowed to ignore liveness");
store->collectGarbage(options, results);
stopWork();
writeStrings(results.paths, to);
writeLongLong(results.bytesFreed, to);
writeLongLong(results.blocksFreed, to);
break;
}
@ -572,7 +572,7 @@ static void performOp(unsigned int clientVersion,
}
break;
}
case wopQuerySubstitutablePathInfos: {
PathSet paths = readStorePaths<PathSet>(from);
startWork();
@ -589,7 +589,7 @@ static void performOp(unsigned int clientVersion,
}
break;
}
case wopQueryAllValidPaths: {
startWork();
PathSet paths = store->queryAllValidPaths();
@ -637,7 +637,7 @@ static void performOp(unsigned int clientVersion,
static void processConnection()
{
canSendStderr = false;
myPid = getpid();
myPid = getpid();
writeToStderr = tunnelStderr;
#ifdef HAVE_HUP_NOTIFICATION
@ -681,7 +681,7 @@ static void processConnection()
stopWork();
to.flush();
} catch (Error & e) {
stopWork(false, e.msg());
to.flush();
@ -690,7 +690,7 @@ static void processConnection()
/* Process client requests. */
unsigned int opCount = 0;
while (true) {
WorkerOp op;
try {
@ -762,7 +762,7 @@ static void daemonLoop()
/* Otherwise, create and bind to a Unix domain socket. */
else {
/* Create and bind to a Unix domain socket. */
fdSocket = socket(PF_UNIX, SOCK_STREAM, 0);
if (fdSocket == -1)
@ -777,7 +777,7 @@ static void daemonLoop()
relative path name. */
chdir(dirOf(socketPath).c_str());
Path socketPathRel = "./" + baseNameOf(socketPath);
struct sockaddr_un addr;
addr.sun_family = AF_UNIX;
if (socketPathRel.size() >= sizeof(addr.sun_path))
@ -802,7 +802,7 @@ static void daemonLoop()
}
closeOnExec(fdSocket);
/* Loop accepting connections. */
while (1) {
@ -810,7 +810,7 @@ static void daemonLoop()
/* Important: the server process *cannot* open the SQLite
database, because it doesn't like forks very much. */
assert(!store);
/* Accept a connection. */
struct sockaddr_un remoteAddr;
socklen_t remoteAddrLen = sizeof(remoteAddr);
@ -819,14 +819,14 @@ static void daemonLoop()
(struct sockaddr *) &remoteAddr, &remoteAddrLen);
checkInterrupt();
if (remote == -1) {
if (errno == EINTR)
continue;
else
throw SysError("accepting connection");
if (errno == EINTR)
continue;
else
throw SysError("accepting connection");
}
closeOnExec(remote);
/* Get the identity of the caller, if possible. */
uid_t clientUid = -1;
pid_t clientPid = -1;
@ -841,13 +841,13 @@ static void daemonLoop()
#endif
printMsg(lvlInfo, format("accepted connection from pid %1%, uid %2%") % clientPid % clientUid);
/* Fork a child to handle the connection. */
pid_t child;
child = fork();
switch (child) {
case -1:
throw SysError("unable to fork");
@ -866,16 +866,16 @@ static void daemonLoop()
string processName = int2String(clientPid);
strncpy(argvSaved[1], processName.c_str(), strlen(argvSaved[1]));
}
/* Since the daemon can be long-running, the
settings may have changed. So force a reload. */
reloadSettings();
/* Handle the connection. */
from.fd = remote;
to.fd = remote;
processConnection();
} catch (std::exception & e) {
std::cerr << format("child error: %1%\n") % e.what();
}
@ -895,7 +895,7 @@ void run(Strings args)
{
bool slave = false;
bool daemon = false;
for (Strings::iterator i = args.begin(); i != args.end(); ) {
string arg = *i++;
if (arg == "--slave") slave = true;