git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Clemens Buchacher <drizzd@aon.at>
To: "Zbigniew Jędrzejewski-Szmek" <zbyszek@in.waw.pl>
Cc: git@vger.kernel.org, gitster@pobox.com, Jeff King <peff@peff.net>
Subject: Re: [PATCH] t5570: forward git-daemon messages in a different way
Date: Sat, 14 Apr 2012 14:13:58 +0200	[thread overview]
Message-ID: <20120414121358.GA26372@ecki> (raw)
In-Reply-To: <1334393070-7123-1-git-send-email-zbyszek@in.waw.pl>

On Sat, Apr 14, 2012 at 10:44:30AM +0200, Zbigniew Jędrzejewski-Szmek wrote:
> git-daemon is not launched properly in t5570:
> 
> $ GIT_TEST_GIT_DAEMON=t ./t5570-git-daemon.sh
> ok 1 - setup repository
> ok 2 - create git-accessible bare repository
> not ok - 3 clone git repository
> not ok - 4 fetch changes via git protocol
> ...
> 
> Current setup code to spawn git daemon (start_git_daemon() in
> lib-git-daemon.sh) redirects daemon output to a pipe, and then
> redirects input from this pipe to a different fd, which is in turn
> connected to a terminal:
>   mkfifo git_daemon_output
>   git daemon ... >&3 2>git_daemon_output
>   {
>       ...
>       cat >&4
>   } <git_daemon_output
> 
> Unfortunately, it seems that the shell (at least bash 4.1-3 from
> debian) closes the pipe and cat doesn't really copy any messages. This
> causes git-daemon to die.

And as a consequence, t5570 tests fail for you? I cannot reproduce with
bash 4.2.24(2). Which git version are you seeing this with?

> Running 'strace -o log cat' instead of just 'cat' shows that no input
> is read:
>   execve("/bin/cat", ...)   = 0
>   ...
>   read(0, "", 8192)         = 0
>   close(0)                  = 0
>   close(1)                  = 0
>   close(2)                  = 0
>   exit_group(0)             = ?

What do you expect it to read? If git-daemon exits without error, it
does not output anything.

> I guess that the shell closes the redirection when exiting the
> {}-delimited part.

I am not sure about that part myself, but it seems to work for me in all
cases.

> It seems easiest to move the cat invocation outside of the
> {}-delimited part and provide a separate redirection which will not be
> closed.

With your patch, only the first line of output will be read from
git-daemon, because the pipe is broken as soon as you close the fifo for
the first time. You can check this by passing an invalid argument to
git-daemon. Only the first line of the usage string will be printed.

In order to better understand the problem on your side, can you execute
this script and tell me what it does for you?

#!/bin/sh

mkfifo fd
yes >fd &
pid=$!
{
	read line
	echo $line
} <fd
cat <fd &
sleep 1
kill $pid
wait $pid
rm -f fd

If we cannot find a reliable solution using shell script, we should
probably write a test-git-daemon wrapper which implements the expected
output checking part in C.

Clemens

  reply	other threads:[~2012-04-14 12:15 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-14  8:44 [PATCH] t5570: forward git-daemon messages in a different way Zbigniew Jędrzejewski-Szmek
2012-04-14 12:13 ` Clemens Buchacher [this message]
2012-04-14 12:21   ` Clemens Buchacher
2012-04-16 15:43     ` Zbigniew Jędrzejewski-Szmek
2012-04-16 17:09       ` Junio C Hamano
2012-04-16 21:22         ` Clemens Buchacher
2012-04-16 22:06           ` Zbigniew Jędrzejewski-Szmek
2012-04-17 15:43             ` Junio C Hamano
2012-04-16 17:42       ` Jeff King
2012-04-16 22:44         ` Clemens Buchacher
2012-04-19  6:03           ` Jeff King
2012-04-19  6:58             ` Johannes Sixt
2012-04-26 13:01               ` Jeff King
2012-04-26 18:16                 ` Johannes Sixt
2012-04-26 19:55                   ` Clemens Buchacher
2012-04-26 21:00                     ` [PATCH] t5570: fix forwarding of git-daemon messages via cat Johannes Sixt
2012-04-26 21:10                       ` Zbigniew Jędrzejewski-Szmek
2012-04-27  7:59                       ` Jeff King
2012-04-27 15:02                       ` Junio C Hamano
2012-04-27  7:55                   ` [PATCH] t5570: forward git-daemon messages in a different way Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120414121358.GA26372@ecki \
    --to=drizzd@aon.at \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    --cc=zbyszek@in.waw.pl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).