Git development
 help / color / mirror / Atom feed
From: "Stephen R. van den Berg" <srb@cuci.nl>
To: Alex Riesen <raa.lkml@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] git-daemon: Simplify child management and associated logging by
Date: Wed, 13 Aug 2008 01:12:10 +0200	[thread overview]
Message-ID: <20080812231210.GB15265@cuci.nl> (raw)
In-Reply-To: <20080812223224.GA4134@steel.home>

Alex Riesen wrote:
>Stephen R. van den Berg, Tue, Aug 12, 2008 23:25:35 +0200:
>> +        struct child*newborn;

>You may want to reformat the patch using tabs instead of spaces.

Tried to do it right, but apparently missed a few spots, thanks.

>> +        newborn = xmalloc(sizeof *newborn);

>The custom here is to use "sizeof(type)". Brackets and typename.

Well, as for the parens, current git source shows a ratio of 26 : 887
in your favour; apparently not everyone agrees, but most do.
As for the typename, that rather uncommon, in most cases actual
variables are used (with good reason).

>> +        if (newborn) {
>> +	        struct child**cradle,*blanket;

>"struct child **cradle, *blanket;" (the spaces before asterisks)

I'll be more careful.

>> +		memcpy(memset(&newborn->address, 0, sizeof newborn->address),
>> +		 addr, addrlen);

>Aren't separate calls easier to read (and type)?

Possibly, yes.

>	memset(&newborn->address, 0, sizeof(newborn->address));
>	memcpy(&newborn->address, addr, addrlen);

But it results in more machinecode in most cases.  Sorry, is my builtin
micro-optimiser at work.

>> -static void kill_some_children(int signo, unsigned start, unsigned stop)
>> +static void kill_some_child(int signo)
>>  {
>> -	start %= MAX_CHILDREN;
>> -	stop %= MAX_CHILDREN;
>> -	while (start != stop) {
>> -		if (!(start & 3))
>> -			kill(live_child[start].pid, signo);
>> -		start = (start + 1) % MAX_CHILDREN;
>> +	const struct child *blanket;
>> +
>> +	if ((blanket = firstborn)) {

>	if (firstborn) {
>	    const struct child *blanket = firstborn;

>You don't even use blanket outside of the "if".

Good thinking.  I restructured the code a few times, previously this
wasn't possible.

>>  static void check_dead_children(void)
>>  {
>> +		loginfo("[%d] Disconnected%s", (int)pid, dead);

>BTW, why do you need that pid_t->int cast?

Because pid_t might be wider than int (unlikely, but possible),
and then this call might crash the program.

>> @@ -1105,6 +1026,10 @@ int main(int argc, char **argv)
>>  			init_timeout = atoi(arg+15);
>>  			continue;

>> +		if (!prefixcmp(arg, "--max-connections=")) {
>> +			max_connections = atoi(arg+18);

>An error checking wouldn't go amiss. And it can't be done with atoi
>(consider strtol).

I merely copied the other argument parsing methods, didn't want to
improve this, just functionally equivalent (will do fine here, IMO).
-- 
Sincerely,
           Stephen R. van den Berg.

Father's Day Special at the local clinic -- Vasectomy!

  reply	other threads:[~2008-08-12 23:13 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-12 19:36 [PATCH] git-daemon: SysV needs the signal handler reinstated Stephen R. van den Berg
2008-08-12 21:25 ` [PATCH] git-daemon: Simplify child management and associated logging by Stephen R. van den Berg
2008-08-12 22:05   ` Junio C Hamano
2008-08-12 22:56     ` Stephen R. van den Berg
2008-08-12 23:52       ` Stephen R. van den Berg
2008-08-13  0:03         ` Stephen R. van den Berg
2008-08-13  0:07         ` Marcus Griep
2008-08-13  0:20       ` Junio C Hamano
2008-08-13  7:36         ` Stephen R. van den Berg
2008-08-13  8:23       ` Stephen R. van den Berg
2008-08-13 19:28       ` Junio C Hamano
2008-08-12 22:32   ` Alex Riesen
2008-08-12 23:12     ` Stephen R. van den Berg [this message]
2008-08-13  6:20       ` Alex Riesen
2008-08-13  7:21         ` Stephen R. van den Berg
2008-08-13  6:41   ` Andreas Ericsson
2008-08-13  7:18     ` Alex Riesen

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=20080812231210.GB15265@cuci.nl \
    --to=srb@cuci.nl \
    --cc=git@vger.kernel.org \
    --cc=raa.lkml@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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox