nix-store --serve: Monitor for client disconnects

This is necessary because build-remote.pl now builds via ‘nix-store
--serve’. So if a build hangs without writing to stdout/stderr, and
the client disconnects, then we need to detect that.
This commit is contained in:
Eelco Dolstra 2014-07-23 19:26:34 +02:00
parent 49fe9592a4
commit 78224cd871

View file

@ -8,6 +8,7 @@
#include "util.hh"
#include "serve-protocol.hh"
#include "worker-protocol.hh"
#include "monitor-fd.hh"
#include <iostream>
#include <algorithm>
@ -879,6 +880,8 @@ static void opServe(Strings opFlags, Strings opArgs)
FdSource in(STDIN_FILENO);
FdSink out(STDOUT_FILENO);
MonitorFdHup monitor(in.fd);
/* Exchange the greeting. */
unsigned int magic = readInt(in);
if (magic != SERVE_MAGIC_1) throw Error("protocol mismatch");