List for cgit developers and users
 help / color / mirror / Atom feed
From: john at keeping.me.uk (John Keeping)
Subject: RFE: .so filters
Date: Fri, 10 Jan 2014 09:06:39 +0000	[thread overview]
Message-ID: <20140110090639.GN7608@serenity.lan> (raw)
In-Reply-To: <CAHmME9q=QGH1gPhbtrzDm5vzSQuTjurGkVfC30jM=GSLyF5gOA@mail.gmail.com>

On Fri, Jan 10, 2014 at 03:11:54AM +0100, Jason A. Donenfeld wrote:
> On Fri, Jan 10, 2014 at 2:41 AM, Jason A. Donenfeld <Jason at zx2c4.com> wrote:
> > and does its thing per usual. At the end, however, it does not exit.
> > Instead of waitpid()ing on it in close filter, we SIGSTOP it, put the
> > fds back in place, etc. Then the next time that filter is called, we
> > SIGCONT it, it reads the first N lines as arguments again, and so
> > forth. I'm most tempted to go with this approach at the moment.
> 
> Problems abound. This has race condition issues, where the parent
> process will SIGSTOP the child before the child can write its output.
> This could be fixed with a more complicated signaling protocol, but
> that's more complex than I'd like it. Back to the drawing board.

This seems drastically over complicated.  Why don't we just have
something like this:

    install_filter:
        if filter_running?
            dup2(filter_stdin, STDOUT_FILENO)
        else
            open_filter

    uninstall_filter:
        read until NUL or EOF

Then the filter just sits waiting for data on stdin and we don't need to
stop it at all.  It does complicate things slightly from where we are
because we can't just let the filters writes to stdout go straight to
our (real) stdout but instead we'll have to read data from it.

Annoyingly, although it is probably good enough in this case, we can't
just do the read in uninstall_filter in case we get to a deadlock where
we want to write to the filter but it's waiting for us to read its
output.  I suspect that means we'd need a thread to do the reading and
set a condition variable when it sees NUL or EOF.

I'd rather put that complexity in CGit and make the filter processes
really simple though - it's better to do the complex bit once than many
times!


  parent reply	other threads:[~2014-01-10  9:06 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-09 21:34 Jason
2014-01-09 22:29 ` mailings
2014-01-09 22:58 ` john
2014-01-10  1:41   ` Jason
2014-01-10  2:11     ` Jason
2014-01-10  4:26       ` Jason
2014-01-10  9:06       ` john [this message]
2014-01-10 15:57         ` Jason
2014-01-10 17:12           ` bluewind
2014-01-10 17:20             ` john
2014-01-10 17:43               ` mricon
2014-01-10 18:00                 ` Jason
2014-01-10 18:00               ` Jason
2014-01-10 17:57             ` Jason
2014-01-10 20:03               ` bluewind
2014-01-10 20:11                 ` john
2014-01-10 20:25                   ` bluewind
2014-01-10 20:36                     ` john
2014-01-10 20:56                       ` bluewind
2014-01-11  2:37                         ` Jason
2014-01-11  2:34                 ` Jason

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=20140110090639.GN7608@serenity.lan \
    --to=cgit@lists.zx2c4.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.
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).