forked from lix-project/lix
Report daemon OOM better
When copying a large path causes the daemon to run out of memory, you now get: error: Nix daemon out of memory instead of: error: writing to file: Broken pipe
This commit is contained in:
parent
829af22759
commit
b1beed97a0
|
@ -402,11 +402,23 @@ Path RemoteStore::addToStore(const Path & _srcPath,
|
||||||
writeInt((hashAlgo == htSHA256 && recursive) ? 0 : 1, to);
|
writeInt((hashAlgo == htSHA256 && recursive) ? 0 : 1, to);
|
||||||
writeInt(recursive ? 1 : 0, to);
|
writeInt(recursive ? 1 : 0, to);
|
||||||
writeString(printHashType(hashAlgo), to);
|
writeString(printHashType(hashAlgo), to);
|
||||||
|
|
||||||
|
try {
|
||||||
to.written = 0;
|
to.written = 0;
|
||||||
to.warn = true;
|
to.warn = true;
|
||||||
dumpPath(srcPath, to, filter);
|
dumpPath(srcPath, to, filter);
|
||||||
to.warn = false;
|
to.warn = false;
|
||||||
processStderr();
|
processStderr();
|
||||||
|
} catch (SysError & e) {
|
||||||
|
/* Daemon closed while we were sending the path. Probably OOM
|
||||||
|
or I/O error. */
|
||||||
|
if (e.errNo == EPIPE)
|
||||||
|
try {
|
||||||
|
processStderr();
|
||||||
|
} catch (EndOfFile & e) { }
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
return readStorePath(from);
|
return readStorePath(from);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -735,11 +735,9 @@ static void processConnection(bool trusted)
|
||||||
during addTextToStore() / importPath(). If that
|
during addTextToStore() / importPath(). If that
|
||||||
happens, just send the error message and exit. */
|
happens, just send the error message and exit. */
|
||||||
bool errorAllowed = canSendStderr;
|
bool errorAllowed = canSendStderr;
|
||||||
if (!errorAllowed) printMsg(lvlError, format("error processing client input: %1%") % e.msg());
|
|
||||||
stopWork(false, e.msg(), GET_PROTOCOL_MINOR(clientVersion) >= 8 ? e.status : 0);
|
stopWork(false, e.msg(), GET_PROTOCOL_MINOR(clientVersion) >= 8 ? e.status : 0);
|
||||||
if (!errorAllowed) break;
|
if (!errorAllowed) throw;
|
||||||
} catch (std::bad_alloc & e) {
|
} catch (std::bad_alloc & e) {
|
||||||
if (canSendStderr)
|
|
||||||
stopWork(false, "Nix daemon out of memory", GET_PROTOCOL_MINOR(clientVersion) >= 8 ? 1 : 0);
|
stopWork(false, "Nix daemon out of memory", GET_PROTOCOL_MINOR(clientVersion) >= 8 ? 1 : 0);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue