[HACKERS] WSAStartup() in libpq

2007-03-08 Thread Magnus Hagander
It has been brought to my attention by Tokuharu Yuzawa that our calling of WSAStartup() in DllMain() (libpqdll.c) is incorrect. Basically we're calling WSAStartup() so that the client application does not have to. However, due to the fact that WSAStartup() can itself load libraries, there is a

Re: [HACKERS] WSAStartup() in libpq

2007-03-08 Thread Andreas Pflug
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

Re: [HACKERS] WSAStartup() in libpq

2007-03-08 Thread Magnus Hagander
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

Re: [HACKERS] WSAStartup() in libpq

2007-03-08 Thread Tom Lane
Magnus Hagander [EMAIL PROTECTED] writes: So I suggest the following simple patch.. Any objections? One wonders if we need DllMain() at all any more. We certainly don't need that switch statement ... Also, isn't the WSACleanup() in freePGconn in the wrong place? Seems like it shouldn't be

Re: [HACKERS] WSAStartup() in libpq

2007-03-08 Thread Magnus Hagander
On Thu, Mar 08, 2007 at 10:10:28AM -0500, Tom Lane wrote: Magnus Hagander [EMAIL PROTECTED] writes: So I suggest the following simple patch.. Any objections? One wonders if we need DllMain() at all any more. We certainly don't need that switch statement ... Indeed. Looking even more into

Re: [HACKERS] WSAStartup() in libpq

2007-03-08 Thread Tom Lane
Magnus Hagander [EMAIL PROTECTED] writes: On Thu, Mar 08, 2007 at 10:10:28AM -0500, Tom Lane wrote: Also, isn't the WSACleanup() in freePGconn in the wrong place? Seems like it shouldn't be done until after we've closed the socket. I'd be inclined to put it at the bottom of the routine.

Re: [HACKERS] WSAStartup() in libpq

2007-03-08 Thread Magnus Hagander
On Thu, Mar 08, 2007 at 10:37:11AM -0500, Tom Lane wrote: Magnus Hagander [EMAIL PROTECTED] writes: On Thu, Mar 08, 2007 at 10:10:28AM -0500, Tom Lane wrote: Also, isn't the WSACleanup() in freePGconn in the wrong place? Seems like it shouldn't be done until after we've closed the socket.

Re: [HACKERS] WSAStartup() in libpq

2007-03-08 Thread Tom Lane
Magnus Hagander [EMAIL PROTECTED] writes: On Thu, Mar 08, 2007 at 10:37:11AM -0500, Tom Lane wrote: Because the calls in DllMain covered us (ie, the WSA usage count never got to be less than one). If we remove them, we'd better get this pair right. But those calls weren't even compiled in