Jason Erickson ([EMAIL PROTECTED]) reports a bug with a severity of 3
The lower the number the more severe it is.

Short Description
LIBPQ Linking with the static library on the WIN32 platform fails connections with 
"unknown host name".

Long Description
I was having problems connecting up to a remote PostgreSQL database when I linked a 
program with the static library, receiving the error "unknown host name: 
198.168.100.254".  I was not experiencing this problem when I linked with the DLL.

Client: Microsoft Visual C++ 6.0, PostgreSQL 7.2.1
Server: FreeBSD 4.4-Stable, PosotgreSQL 7.2.1

I traced this down to the fact that with the static version of the library, the 
WinSock initialization functions are not being called (WSAStartup).  The DLL calls the 
WinSock initialization function in the DllMain function.

I have included what I used to patch the file fe-connect.c in the example code 
section.  This solution calls WSAStartup for every connection and WSACleanup for every 
closing call.  I am not sure if I have all the exit paths.  This patch might not be 
the best way to solve the problem, since the initialization function only needs to be 
called once, not for every connection.



Sample Code
834c834,843
< 
---
> #if WIN32
>               WSADATA wsaData;
>               if (WSAStartup(MAKEWORD(1, 1), &wsaData))
>               {
>                       printfPQExpBuffer(&conn->errorMessage,
>                         libpq_gettext("Unable to Initialize WSA\n"));
>                       goto connect_errReturn;
>               }
>               WSASetLastError(0);
> #endif
988a998
>                       WSACleanup();
1029a1040
>               WSACleanup();
1909a1921
>               WSACleanup();
1982a1995
>               WSACleanup();
2159a2173
>       WSACleanup();


No file was uploaded with this report


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Reply via email to