Home > Archive > PostgreSQL Bugs > May 2005 > Re: BUG #1545: LIBPQ Windows Version not calling WSACleanup for









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: BUG #1545: LIBPQ Windows Version not calling WSACleanup for
Bruce Momjian

2005-05-05, 11:24 am

Jason Erickson wrote:
> Taken from microsoft at:
> http://msdn.microsoft.com/library/d...-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

Tom Lane

2005-05-05, 11:24 am

Bruce Momjian <pgman@candle.pha.pa.us> writes:
> 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.


Go ahead and put it in --- I'll wait for your commit.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Tom Lane

2005-05-05, 11:24 am

Bruce Momjian <pgman@candle.pha.pa.us> writes:
> Jason Erickson wrote:
[color=darkred]
> 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.


Actually ... why do we need a WSAStartup in makeEmptyPGconn? If we have
one in DLL attach, isn't that sufficient?

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql
.org so that your
message can get through to the mailing list cleanly

Bruce Momjian

2005-05-05, 11:24 am

Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
>
>
> Actually ... why do we need a WSAStartup in makeEmptyPGconn? If we have
> one in DLL attach, isn't that sufficient?


The DLL attach function in libpqdll.c is only linked into the binary
when we are doing a WIN32_CLIENT_ONLY build from one of the *.mak files
with MSVC or BCC. It isn't linked in using the standard Makefile under
MinGW.

Seems the proper solution is to link in libpqdll.c for all Win32 builds,
and remove the WSAStartup() call from fe-connect.c, rather than call it
for every connection request. Of course that is only for CVS HEAD.

However, the addition of WSACleanup() is so minor and hard to test that
I would rather do it after 8.0.3 is packaged.

--
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

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com