Re: WSAStartup() in libpq

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Andreas Pflug <pgadmin(at)pse-consulting(dot)de>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: WSAStartup() in libpq
Date: 2007-03-08 12:21:34
Message-ID: 20070308122134.GD7216@svr2.hagander.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Mar 08, 2007 at 12:47:42PM +0100, Andreas Pflug wrote:
> Magnus Hagander wrote:
> >
> > The easy fix for this is to remove the calls. Which obviously will break
> > some client apps. A fairly easy fix for the WSAStartup() call is to have
> > a check in the connection functions against a global variable that will
> > then make sure to call WSAStartup() the first time it's called.
> >
> > That would leave us "leaking" the WSAStartup() call, but only one per
> > application. This is not perfect, but I'm thinking we can maybe live
> > with that.
> >
> > If not, perhaps we can have it call WSAStartup() everytime we connect to
> > a server, and then WSACleanup() when we shut down that connection with
> > PQfinish().
>
> Taken from MSDN docs, this seems the recommended solution. After the
> first WSAStartup call subsequent calls are cheap because they only
> increment a counter.

Now that I look closer at it, we *already* do WSAStartup() in
makeEmptyPGconn... And free it in freePGconn().

So I suggest the following simple patch.. Any objections?

//Magnus

Attachment Content-Type Size
libpq.diff text/plain 1.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavan Deolasee 2007-03-08 12:43:25 Re: Bug in VACUUM FULL ?
Previous Message Andreas Pflug 2007-03-08 11:47:42 Re: WSAStartup() in libpq