git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Lars Schneider <larsxschneider@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>, Johannes Sixt <j6t@kdbg.org>
Subject: Re: Looking for help to understand external filter driver code
Date: Tue, 19 Jul 2016 10:56:00 -0700	[thread overview]
Message-ID: <xmqqbn1th5qn.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <67D9AC88-550E-4549-9AFD-2401B70B363B@gmail.com> (Lars Schneider's message of "Tue, 19 Jul 2016 18:40:48 +0200")

Lars Schneider <larsxschneider@gmail.com> writes:

> a long time ago in aa4ed4 Junio introduced the external filter
> driver definition. Since that time we fork the Git process and
> then we fork again to run the external filter. This is probably a
> super stupid question with an obvious answer... but can anyone
> help me to understand the code and explain why we fork twice?

In "git show aa4ed4" you find this picture:

       /*
        * Create a pipeline to have the command filter the buffer's
        * contents.
        *
        * (child --> cmd) --> us
        */

where "child" is a fork of the original Git process; it still has
the <src, size> buffered data inherited from the original process,
so it can write_in_full() into the pipe going to the cmd process.
"us" is the original process that has the reading end of the pipe
that connects us to the "(child --> cmd)" processes, so that it can
read the filtered result from them.

The key benefit of this arrangement is the above can be done without
having to do poll() to flip between reading and writing that is
needed to avoid deadlocking, which kept the code simpler.  A later
conversion of the write side into async does not fundamentally
change anything from the original arrangement.







  reply	other threads:[~2016-07-19 17:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-19 16:40 Looking for help to understand external filter driver code Lars Schneider
2016-07-19 17:56 ` Junio C Hamano [this message]
2016-07-19 18:53   ` Junio C Hamano
2016-07-19 20:44     ` Lars Schneider
2016-07-19 21:33       ` Junio C Hamano
2016-07-19 22:01         ` Lars Schneider
2016-07-20  2:33           ` Torsten Bögershausen
2016-07-20  8:59         ` Jakub Narębski
2016-07-20  9:43           ` Lars Schneider
2016-07-20 13:49         ` 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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=xmqqbn1th5qn.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=j6t@kdbg.org \
    --cc=larsxschneider@gmail.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).