All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
To: git@vger.kernel.org
Cc: gitster@pobox.com,
	Jeremie Nikaes <jeremie.nikaes@ensimag.imag.fr>,
	Arnaud Lacurie <arnaud.lacurie@ensimag.imag.fr>,
	Claire Fousse <claire.fousse@ensimag.imag.fr>,
	David Amouyal <david.amouyal@ensimag.imag.fr>
Subject: Clean termination of remote-helpers (was Re: [PATCH 2/2] Add a remote helper to interact with mediawiki (fetch & push))
Date: Wed, 31 Aug 2011 14:33:19 +0200	[thread overview]
Message-ID: <vpqd3flzrow.fsf_-_@bauges.imag.fr> (raw)
In-Reply-To: <1314378689-8997-2-git-send-email-Matthieu.Moy@imag.fr> (Matthieu Moy's message of "Fri, 26 Aug 2011 19:11:29 +0200")

Matthieu Moy <Matthieu.Moy@imag.fr> writes:

> +BEGIN { $| = 1 };
> +if (!eof(STDIN)) {
> +	# Wait for Git to terminate. If we don't, git fetch
> +	# (transport-helper.c's sendline function) will try to write
> +	# to our stdin, which will be closed, and git fetch will be
> +	# killed. That's probably a bug in transport-helper.c, but in
> +	# the meantime ...
> +	sleep .1;
> +};

I was expecting this part to be more controversial, so I'm just
repeating it to draw more attention ;-).

I just found a "cleaner" way to terminate, but I still don't find it
really satisfactory:

# Inform Git that we're done, otherwise Git won't close it's stdin,
# and the next loop will be infinite.
close(STDOUT);
# Flush stdin before we terminate. If we don't, git fetch
# (transport-helper.c's sendline function) will try to write to our
# stdin, which may be closed, and git fetch will be killed. That's
# probably a bug in transport-helper.c, but in the meantime ...
while (<STDIN>) {};

This seems reliable (just did 100+ imports without crash).

If I comment-out the "close(STDOUT)", then the while loop is indeed
infinite. If I comment-out the "while (<STDIN>) {};", then the import
unreliably fails (for example, I just did 10 clones of a 1-page wiki,
and got one failure). No error message, just a non-zero exit status, and
in the case of "clone", the newly created repository is deleted before
the command terminates.

With debug activated in transport-helper.c, the last messages are just:

Debug: Disconnecting.
Debug: Remote helper: -> 

and gdb says:

Program received signal SIGPIPE, Broken pipe.
0xb7fe2424 in __kernel_vsyscall ()
(gdb) bt
#0  0xb7fe2424 in __kernel_vsyscall ()
#1  0xb7e66ff3 in __write_nocancel () at ../sysdeps/unix/syscall-template.S:82
#2  0x0811dc08 in xwrite (fd=8, buf=0x81bd840, len=1) at wrapper.c:137
#3  0x0811dc67 in write_in_full (fd=8, buf=0x81bd840, count=1) at wrapper.c:169
#4  0x08115035 in sendline (helper=0x81a2d00, buffer=0xbfffe674) at transport-helper.c:41
#5  0x081158f3 in disconnect_helper (transport=0x81a2cc0) at transport-helper.c:231
#6  release_helper (transport=0x81a2cc0) at transport-helper.c:324
#7  0x08111f1d in transport_disconnect (transport=0x81a2cc0) at transport.c:1144
#8  0x08061711 in cmd_clone (argc=3, argv=0xbfffeb58, prefix=0x0) at builtin/clone.c:739
#9  0x0804ba27 in run_builtin (argc=<value optimized out>, argv=<value optimized out>) at git.c:308
#10 handle_internal_command (argc=<value optimized out>, argv=<value optimized out>) at git.c:466
#11 0x0804bc33 in run_argv (argc=3, argv=0xbfffeb58) at git.c:512
#12 main (argc=3, argv=0xbfffeb58) at git.c:585

Any idea how to fix this?

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

  parent reply	other threads:[~2011-08-31 12:33 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-26 17:11 [PATCH 1/2] fast-import: initialize variable require_explicit_termination Matthieu Moy
2011-08-26 17:11 ` [PATCH 2/2] Add a remote helper to interact with mediawiki (fetch & push) Matthieu Moy
2011-08-26 17:53   ` Junio C Hamano
2011-08-29  5:42     ` Sverre Rabbelier
2011-08-29  6:05       ` Junio C Hamano
2011-08-29  6:41         ` Sverre Rabbelier
2011-08-30  3:56           ` Jonathan Nieder
2011-08-30 17:13             ` Junio C Hamano
2011-08-31 11:54             ` Matthieu Moy
2011-09-01 23:44               ` Jonathan Nieder
2011-08-31 12:05           ` done feature in remote-helpers (was Re: [PATCH 2/2] Add a remote helper to interact with mediawiki (fetch & push)) Matthieu Moy
2011-08-31 12:17             ` Sverre Rabbelier
2011-08-31 12:55               ` Matthieu Moy
2011-08-31 12:58                 ` Sverre Rabbelier
2011-08-31 13:12                   ` Matthieu Moy
2011-08-31 13:16                     ` Sverre Rabbelier
2011-08-31 16:47                       ` [PATCH] git-remote-helpers.txt: explain how import works with multiple refs Matthieu Moy
2011-08-31 18:14                         ` [PATCH] (short) documentation for the testgit remote helper Matthieu Moy
2011-09-01 11:27                           ` Sverre Rabbelier
2011-09-01 15:52                             ` Matthieu Moy
2011-09-01 16:49                               ` [PATCH 1/2 v2] Documentation/git-remote-helpers: explain how import works with multiple refs Matthieu Moy
2011-09-01 16:49                                 ` [PATCH 2/2 v2] (short) documentation for the testgit remote helper Matthieu Moy
2011-09-01 16:59                                   ` Sverre Rabbelier
2011-09-01 16:59                                 ` [PATCH 1/2 v2] Documentation/git-remote-helpers: explain how import works with multiple refs Sverre Rabbelier
2011-09-01 11:24                         ` [PATCH] git-remote-helpers.txt: " Sverre Rabbelier
2011-09-01 23:17                         ` Jonathan Nieder
2011-09-03 10:35                           ` Matthieu Moy
2011-08-26 17:55   ` [PATCH v5] Add a remote helper to interact with mediawiki (fetch & push) Matthieu Moy
2011-08-31 16:55     ` [PATCH v6] " Matthieu Moy
2011-08-31 17:03       ` Sverre Rabbelier
2011-08-31 17:30         ` Matthieu Moy
2011-09-01  0:24           ` Junio C Hamano
2011-09-01  5:26             ` Matthieu Moy
2011-09-01 16:54               ` [PATCH 0/2] Git-MediaWiki Matthieu Moy
2011-09-01 16:54                 ` [PATCH 1/2 v7] Add a remote helper to interact with mediawiki (fetch & push) Matthieu Moy
2011-09-01 16:54                 ` [PATCH 2/2] git-remote-mediawiki: allow push to set MediaWiki metadata Matthieu Moy
2011-08-31 12:33   ` Matthieu Moy [this message]
2011-08-31 13:25     ` Clean termination of remote-helpers (was Re: [PATCH 2/2] Add a remote helper to interact with mediawiki (fetch & push)) Sverre Rabbelier
2011-08-31 14:53       ` Matthieu Moy
2011-08-31 15:00         ` Sverre Rabbelier
2011-08-26 17:51 ` [PATCH 1/2] fast-import: initialize variable require_explicit_termination Junio C Hamano
2011-08-26 17:59   ` Matthieu Moy
2011-08-26 18:55     ` Junio C Hamano

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=vpqd3flzrow.fsf_-_@bauges.imag.fr \
    --to=matthieu.moy@grenoble-inp.fr \
    --cc=arnaud.lacurie@ensimag.imag.fr \
    --cc=claire.fousse@ensimag.imag.fr \
    --cc=david.amouyal@ensimag.imag.fr \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jeremie.nikaes@ensimag.imag.fr \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.