git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: git@vger.kernel.org, Mark Levedahl <mdl123@verizon.net>, junkio@cox.net
Subject: Re: [PATCH] Add git-bundle: move objects and references by archive
Date: Wed, 21 Feb 2007 23:08:08 -0800	[thread overview]
Message-ID: <7v4ppellev.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <7v8xeqllxk.fsf@assigned-by-dhcp.cox.net> (Junio C. Hamano's message of "Wed, 21 Feb 2007 22:56:55 -0800")

Junio C Hamano <junkio@cox.net> writes:

>> +static int verify_bundle(struct bundle_header *header)
>> +{
>> +	/*
>> +	 * Do fast check, then if any prereqs are missing then go line by line
>> +	 * to be verbose about the errors
>> +	 */
>> +	struct ref_list *p = &header->prerequisites;
>> +	const char *argv[5] = {"rev-list", "--stdin", "--not", "--all", NULL};
>> +	int pid, in, out, i, ret = 0;
>> +	char buffer[1024];
>> +
>> +	in = out = -1;
>> +	pid = fork_with_pipe(argv, &in, &out);
>> +	if (pid < 0)
>> +		return error("Could not fork rev-list");
>> +	if (!fork()) {
>> +		for (i = 0; i < p->nr; i++) {
>> +			write(in, sha1_to_hex(p->list[i].sha1), 40);
>> +			write(in, "\n", 1);
>> +		}
>> +		close(in);
>> +		exit(0);
>> +	}
>> +	close(in);
>
> What if write() fails?  That can happen when one of the objects
> you feed here, or its parent objects, is missing from your
> repository -- receiving rev-list would die() and the writing
> child would sigpipe.
>
> I also wonder who waits for this child...

In general, fork() to avoid bidirectional pipe deadlock is a
good discipline, but in this particular case I think it would be
easier to handle errors if you don't (and it would save another
process).  The other side "rev-list --stdin --not --all" is
running a limited traversal, and would not emit anything until
you stop feeding it from --stdin, or until it dies because you
fed it a commit that does not exist.  So as long as you check
the error condition from write() for EPIPE to notice the other
end died, I think you are Ok.

  reply	other threads:[~2007-02-22  7:08 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <Pine.LNX.4.63.0702220157130.22628@wbgn013.biozentrum.uni-wuerz burg.de>
2007-02-22  0:59 ` [PATCH] Add git-bundle: move objects and references by archive Johannes Schindelin
2007-02-22  3:28   ` Nicolas Pitre
2007-02-22 15:55     ` Johannes Schindelin
2007-02-22 16:14       ` Simon 'corecode' Schubert
2007-02-22 16:28         ` Nicolas Pitre
2007-02-22 16:37         ` Johannes Schindelin
2007-02-22 16:46           ` Simon 'corecode' Schubert
2007-02-22 17:09             ` Johannes Schindelin
2007-02-22 16:24       ` Nicolas Pitre
2007-02-22 17:12         ` Johannes Schindelin
2007-02-22 17:21           ` Nicolas Pitre
2007-02-22  6:56   ` Junio C Hamano
2007-02-22  7:08     ` Junio C Hamano [this message]
2007-02-22 16:20       ` Johannes Schindelin
2007-02-22 19:10         ` Junio C Hamano
2007-02-22 19:16           ` Johannes Schindelin
2007-02-22 20:05             ` Junio C Hamano
2007-02-22 20:25               ` Johannes Schindelin
2007-02-22 16:17     ` Johannes Schindelin
2007-02-23  2:32     ` Mark Levedahl
2007-02-23  4:39       ` Junio C Hamano
2007-02-22  9:31   ` Johannes Sixt
2007-02-22 18:14   ` [PATCH] git-bundle: assorted fixes Johannes Schindelin
2007-02-23  1:36     ` Mark Levedahl
2007-02-23  1:56       ` Johannes Schindelin
2007-02-23  2:12         ` Mark Levedahl
2007-02-23  2:17           ` Johannes Schindelin
2007-02-23  3:37             ` Mark Levedahl
2007-02-18 22:47 [PATCH] Add git-bundle: move objects and references by archive Mark Levedahl
2007-02-19  1:07 ` Johannes Schindelin
2007-02-19  1:50   ` Junio C Hamano
2007-02-19  2:02     ` Johannes Schindelin
2007-02-19  7:56   ` Shawn O. Pearce
2007-02-19 13:29   ` Mark Levedahl
2007-02-19 15:03     ` Johannes Schindelin
2007-02-19  1:49 ` Junio C Hamano
  -- strict thread matches above, loose matches on Subject: below --
2007-02-17 18:41 [PATCH] Add git-unbundle - unpack objects and references for disconnected transfer Junio C Hamano
2007-02-18 17:27 ` [PATCH] Add git-bundle: move objects and references by archive Mark Levedahl
2007-02-18 22:47   ` Mark Levedahl

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=7v4ppellev.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=mdl123@verizon.net \
    /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).