Jason Erickson wrote:
> Taken from microsoft at:
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/win
> sock/wsastartup_2.asp
> -------------------------------------------------------
> An application must call one WSACleanup call for every successful WSAStartup
> call to allow third-party DLLs to make use of a WS2_32.DLL on behalf of an
> application. This means, for example, that if an application calls
> WSAStartup three times, it must call WSACleanup three times. The first two
> calls to WSACleanup do nothing except decrement an internal counter; the
> final WSACleanup call for the task does all necessary resource deallocation
> for the task.
> ------------------------------------------------------------------
>
> The only place WSACleanup is being called is libpqdll when the process
> detaches the DLL (if the libpq is not staticly linked in), which matches up
> with the WSAStartup when the process attaches to the DLL.
>
> The WSAStartup in the fe-connect.c->makeEmptyPGconn() does not have a
> matching WSACleanup. WSACleanup could possibly be placed in freePGconn(),
> but unsure if all possible error cases will go through this function.
>
> This problem exists in both 8.0.1 and 7.4.7 of the libpq interface for
> Windows.
I agree freePGconn() is the proper place. I will apply the following
patch to current CVS and to 8.0.X. 8.0.3 is being packaged now so I
will wait for 8.0.4.
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
Index: src/interfaces/libpq/fe-connect.c
===================================================================
RCS file: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v
retrieving revision 1.304
diff -c -c -r1.304 fe-connect.c
*** src/interfaces/libpq/fe-connect.c 25 Mar 2005 00:34:29 -0000 1.304
--- src/interfaces/libpq/fe-connect.c 5 May 2005 15:43:06 -0000
***************
*** 2034,2039 ****
--- 2034,2043 ----
PGnotify *notify;
pgParameterStatus *pstatus;
+ #ifdef WIN32
+ WSACleanup();
+ #endif
+
if (!conn)
return;