aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-03-04 08:12:15 +0100
committereldritch horrors <pennae@lix.systems>2024-03-04 08:12:15 +0100
commit68f148ed45da0a8b827a96611e7825d5d2396454 (patch)
treeb47bbaa1fdb1613cbff4d45970f901f2b08c5f87 /src
parent5dd872363a8fff8d2a1d4ed182c8112221e4dfb1 (diff)
Merge pull request #9798 from edolstra/remote-store-eof
Print a more helpful message if the daemon crashes (cherry picked from commit 32706b14a7531c2c21b9f96da083a540a0031ec4) Change-Id: Ief7c465bca7666e2b7e7c9d1dd0c01c5f9014146
Diffstat (limited to 'src')
-rw-r--r--src/libstore/remote-store.cc1
-rw-r--r--src/libutil/serialise.cc2
-rw-r--r--src/libutil/serialise.hh5
3 files changed, 5 insertions, 3 deletions
diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc
index 2f4933577..58fac40dc 100644
--- a/src/libstore/remote-store.cc
+++ b/src/libstore/remote-store.cc
@@ -65,6 +65,7 @@ void RemoteStore::initConnection(Connection & conn)
{
/* Send the magic greeting, check for the reply. */
try {
+ conn.from.endOfFileError = "Nix daemon disconnected unexpectedly (maybe it crashed?)";
conn.to << WORKER_MAGIC_1;
conn.to.flush();
StringSink saved;
diff --git a/src/libutil/serialise.cc b/src/libutil/serialise.cc
index 910a760a9..6b0d87b03 100644
--- a/src/libutil/serialise.cc
+++ b/src/libutil/serialise.cc
@@ -128,7 +128,7 @@ size_t FdSource::readUnbuffered(char * data, size_t len)
n = ::read(fd, data, len);
} while (n == -1 && errno == EINTR);
if (n == -1) { _good = false; throw SysError("reading from file"); }
- if (n == 0) { _good = false; throw EndOfFile("unexpected end-of-file"); }
+ if (n == 0) { _good = false; throw EndOfFile(std::string(*endOfFileError)); }
read += n;
return n;
}
diff --git a/src/libutil/serialise.hh b/src/libutil/serialise.hh
index 333c254ea..d1c791823 100644
--- a/src/libutil/serialise.hh
+++ b/src/libutil/serialise.hh
@@ -151,12 +151,13 @@ struct FdSource : BufferedSource
{
int fd;
size_t read = 0;
+ BackedStringView endOfFileError{"unexpected end-of-file"};
FdSource() : fd(-1) { }
FdSource(int fd) : fd(fd) { }
- FdSource(FdSource&&) = default;
+ FdSource(FdSource &&) = default;
- FdSource& operator=(FdSource && s)
+ FdSource & operator=(FdSource && s)
{
fd = s.fd;
s.fd = -1;