git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] GIT: Listen on IPv6 as well, if available.

From
Petr Baudis <pasky@suse.cz>
Date
Jul 22, 2005, 21:21 UTC
Message-ID
<20050722212151.GI11916@pasky.ji.cz>
In-Reply-To
<20050721.091049.46807257.yoshfuji@linux-ipv6.org>

Dear diary, on Thu, Jul 21, 2005 at 03:10:49PM CEST, I got a letter where "YOSHIFUJI Hideaki / ?$B5HF#1QL@" <yoshfuji@linux-ipv6.org> told me that...

> Hello.
Hello from an IPv6 fan,
Show 11 quoted lines
> Listen on IPv6 as well, if available.
> 
> Signed-off-by: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
> 
> diff --git a/daemon.c b/daemon.c
> --- a/daemon.c
> +++ b/daemon.c
> @@ -219,37 +219,102 @@ static void child_handler(int signo)
>  
>  static int serve(int port)
>  {
..snip..

this whole getaddrinfo() magic looks horribly complicated. What's wrong on just adding a similar code (or factoring it out to a function) for IPv6 as there is for IPv4, just s/INET/INET6/?

Show 15 quoted lines
>  	for (;;) {
> -		struct sockaddr_in in;
> -		socklen_t addrlen = sizeof(in);
> -		int incoming = accept(sockfd, (void *)&in, &addrlen);
> -
> -		if (incoming < 0) {
> -			switch (errno) {
> -			case EAGAIN:
> -			case EINTR:
> -			case ECONNABORTED:
> -				continue;
> -			default:
> -				die("accept returned %s", strerror(errno));
> +		struct sockaddr_storage ss;
> +		socklen_t sslen = sizeof(ss);

Perhaps move those to the most inner block. (All right, I'm nitpicking too much again, sorry.)

Show 6 quoted lines
> +
> +		int i;
> +		fds = fds_init;
> +		
> +		if (select(maxfd + 1, &fds, NULL, NULL, NULL) == -1) {
> +			/* warning? */

Certainly a warning and at least sleep(1) to avoid cpuburn-like behaviour in case of anything going wrong.

Show 24 quoted lines
> +			continue;
> +		}
> +
> +		for (i = 0; i < socknum; i++) {
> +			int sockfd = socklist[i];
> +
> +			if (FD_ISSET(sockfd, &fds)) {
> +				int incoming = accept(sockfd, (struct sockaddr *)&ss, &sslen);
> +				if (incoming < 0) {
> +					switch (errno) {
> +					case EAGAIN:
> +					case EINTR:
> +					case ECONNABORTED:
> +						continue;
> +					default:
> +						die("accept returned %s", strerror(errno));
> +					}
> +				}
> +				handle(incoming, (struct sockaddr *)&ss, sslen);
>  			}
>  		}
> -		handle(incoming, &in, addrlen);
>  	}
>  }
-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
If you want the holes in your knowledge showing up try teaching
someone.  -- Alan Cox
Previous: YOSHIFUJI Hideaki / 吉藤英明Next: YOSHIFUJI Hideaki / 吉藤英明
Message 2 of 4 in “GIT: Listen on IPv6 as well, if available.”
  1. 2/2 GIT: Listen on IPv6 as well, if available.YOSHIFUJI Hideaki / 吉藤英明, Jul 21, 2005
  2. Petr BaudisJul 22, 2005
  3. YOSHIFUJI Hideaki / 吉藤英明Jul 22, 2005
  4. Petr BaudisJul 22, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.