Re: Clean termination of remote-helpers (was Re: [PATCH 2/2] Add a remote helper to interact with mediawiki (fetch & push))

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sverre Rabbelier <srabbelier@xxxxxxxxx> writes:

> Heya,
>
> On Wed, Aug 31, 2011 at 14:33, Matthieu Moy
> <Matthieu.Moy@xxxxxxxxxxxxxxx> wrote:
>> I was expecting this part to be more controversial, so I'm just
>> repeating it to draw more attention ;-).
>
> Eek! :)
>
>> # 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>) {};
>
> Is this caused by you not reading the terminating '\n' that git sends
> when all commands are done?

Indeed. The stream sent by git looks like

import HEAD
import refs/heads/master
\n <-- this one closes the sequence of import
\n <-- this one closes the sequence of commands.

and I was interpreting it as

import HEAD
import refs/heads/master
\n <-- this one closes the sequence of commands
\n <-- what's this??

So it seems the only bug I've found is insufficient documentation. A
patch follows.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]