git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Sixt <j.sixt@viscovery.net>
To: "Martin Storsjö" <martin@martin.st>
Cc: git@vger.kernel.org, gitster@pobox.com
Subject: Re: [PATCH 1/2] Refactor winsock initialization into a separate  function
Date: Tue, 24 Nov 2009 08:36:21 +0100	[thread overview]
Message-ID: <4B0B8CF5.6080208@viscovery.net> (raw)
In-Reply-To: <alpine.DEB.2.00.0911240054420.14228@cone.home.martin.st>

Martin Storsjö schrieb:
> Signed-off-by: Martin Storsjo <martin@martin.st>

I have used this series in my tree for 6 weeks without negative
sideffects. I haven't tested IPv6, though.

Here's an updated commit message with my ACK:

--- >8 ---
Refactor winsock initialization into a separate function

The winsock library must be initialized. Since gethostbyname() is the
first function that calls into winsock, it was overridden to do the
initialization. This refactoring helps the next patch, where other
functions can be called earlier.

Signed-off-by: Martin Storsjo <martin@martin.st>
Acked-by: Johannes Sixt <j6t@kdbg.org>
--- >8 ---


> ---
>  compat/mingw.c |   15 ++++++++++++---
>  1 files changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/compat/mingw.c b/compat/mingw.c
> index 15fe33e..f9d82ff 100644
> --- a/compat/mingw.c
> +++ b/compat/mingw.c
> @@ -903,16 +903,25 @@ char **make_augmented_environ(const char *const *vars)
>  	return env;
>  }
>  
> -/* this is the first function to call into WS_32; initialize it */
> -#undef gethostbyname
> -struct hostent *mingw_gethostbyname(const char *host)
> +static void ensure_socket_initialization(void)
>  {
>  	WSADATA wsa;
> +	static int initialized = 0;
> +
> +	if (initialized)
> +		return;
>  
>  	if (WSAStartup(MAKEWORD(2,2), &wsa))
>  		die("unable to initialize winsock subsystem, error %d",
>  			WSAGetLastError());
>  	atexit((void(*)(void)) WSACleanup);
> +	initialized = 1;
> +}
> +
> +#undef gethostbyname
> +struct hostent *mingw_gethostbyname(const char *host)
> +{
> +	ensure_socket_initialization();
>  	return gethostbyname(host);
>  }
>  

  reply	other threads:[~2009-11-24  7:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-23 22:54 [PATCH 0/2] Add support for IPv6 on MinGW Martin Storsjö
2009-11-23 22:55 ` [PATCH 1/2] Refactor winsock initialization into a separate function Martin Storsjö
2009-11-24  7:36   ` Johannes Sixt [this message]
2009-11-23 22:55 ` [PATCH 2/2] Enable support for IPv6 on MinGW Martin Storsjö
2009-11-24  7:41   ` Johannes Sixt
2009-11-24  0:58 ` [PATCH 0/2] Add " Junio C Hamano
2009-11-24 11:41   ` Martin Storsjö

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=4B0B8CF5.6080208@viscovery.net \
    --to=j.sixt@viscovery.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=martin@martin.st \
    /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;
as well as URLs for NNTP newsgroup(s).