From: Clemens Buchacher Date: Sun, 15 Apr 2012 19:32:42 GMT Subject: Re: [PATCH] git-daemon wrapper to wait until daemon is ready Message-ID: <20120415193242.GA1960@ecki> In-Reply-To: <4F8B0158.4040407@kdbg.org> On Sun, Apr 15, 2012 at 07:11:52PM +0200, Johannes Sixt wrote: > > But reading the first line in this way needs a few assumptions to be true: > > - git-daemon does not write an incomplete line and then waits. Yes. One way to avoid that assumption would be a timeout. > - git-daemon does not write more than one line, because xread() happily > reads everything it can get. Your implementation differs from the old > version because the shell's 'read' is required to read no more than one > line, i.e., to read byte-wise from the pipe until it sees the LF. The strbuf_getwholeline_fd implementation calls xread(fd, buf, 1), reading only one byte at a time. It does not try to read beyond the newline.