Re: [PATCH v4 11/15] daemon: report connection from root-process
- From
Erik Faye-Lund <kusmabite@gmail.com>
- Date
- Oct 14, 2010, 10:50 UTC
- Message-ID
- <AANLkTinXNPWaGj2BUaSOJypzv-Sqts-zEdG886oT2YJB@mail.gmail.com>
- In-Reply-To
- <7vlj61hfe7.fsf@alter.siamese.dyndns.org>
On Thu, Oct 14, 2010 at 12:55 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 40 quoted lines
> Erik Faye-Lund <kusmabite@gmail.com> writes:
>
>> Report incoming connections from the process that
>> accept() the connection instead of the handling
>> process.
>>
>> This enables "Connection from"-reporting on
>> Windows, where getpeername(0, ...) consistently
>> fails.
>>
>> Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
>> ---
>> daemon.c | 72 ++++++++++++++++++++++++++++++-------------------------------
>> 1 files changed, 35 insertions(+), 37 deletions(-)
>>
>> diff --git a/daemon.c b/daemon.c
>> index 8a44fb9..1574f75 100644
>> --- a/daemon.c
>> +++ b/daemon.c
>> @@ -516,38 +516,11 @@ static void parse_host_arg(char *extra_args, int buflen)
>> }
>>
>>
>> -static int execute(struct sockaddr *addr)
>> +static int execute(void)
>> {
>> -...
>> - }
>> - loginfo("Connection from %s:%d", addrbuf, port);
>> - setenv("REMOTE_ADDR", addrbuf, 1);
>> ...
>> + else {
>> + loginfo("[%"PRIuMAX"] Connection from %s:%d",
>> + (uintmax_t)cld.pid, addrstr, port);
>> add_child(&cld, addr, addrlen);
>
> Hmm, loginfo() calls logreport() and adds the process information as
> necessary to the output. Wouldn't this patch give the pid information
> twice?
>Close, but not quite. logreport() reports the current PID, while this call to loginfo reports the PID of the child process. So two non-identical PIDs are reported.
The output becomes something like this:
[6408] [3868] Connection from [::1]:55801 [3868] Extended attributes (16 bytes) exist <host=localhost> [3868] Request upload-pack for '/some-repo.git' [3868] '/some-repo.git' does not appear to be a git repository [6408] [1876] Connection from [::1]:57311 [1876] Extended attributes (16 bytes) exist <host=localhost> [1876] Request upload-pack for '/some-repo.git' [1876] '/some-repo.git' does not appear to be a git repository