Hi,

in the last few days I compiled libpq on Windows NT
using MS Visual Studio 6.0. I followed the instructions
given by Bob Kline <bkline@rksystems.com> in his mail from
Fri, 3 Sep 1999.
Unfortuanetely he sent his mail only to dbi-users, so I would
like to repeat one major problem on this list.

Here is an excerpt from his mail:

4. The DllMain function in src/interfaces/libpq/libpqdll.c of the
PostgreSQL 6.5 sources, in which WSAStartup is invoked, is never called,
which causes gethostbyname calls to fail.  Solution (more properly,
"kludge" -- I know there's a cleaner fix somewhere, but this works for
now): immediately after the local declarations for the connectDB function
in src/interfaces/libpq/fe-connect.c:

#ifdef WIN32
    static int WeHaveCalledWSAStartup;

    if (!WeHaveCalledWSAStartup) {
        WSADATA wsaData;
        if (WSAStartup(MAKEWORD(1, 1), &wsaData)) {
            sprintf(conn->errorMessage,
                    "WSAStartup failed: errno=%d\n", h_errno);
            goto connect_errReturn;
        }
        WeHaveCalledWSAStartup = 1;
    }
#endif



Besides the effort to port the complete server om Win32
using the Cygnus environment, it would be nice to be able
to compile at least the client part (libpq) with a standard
MS-compiler.

So please apply this patch or an equivalent cleaner solution.


thanks
Edmund


-- 
Edmund Mergl
mailto:E.Mergl@bawue.de
http://www.bawue.de/~mergl

Thu, 30 Sep 1999 07:24:34 +0200
Edmund Mergl <E.Mergl@bawue.de>
Win32 =?iso-8859-1?Q?p=FCort?= of libpq

On 30-Sep-99 Edmund Mergl wrote:
> Hi,
> 
> in the last few days I compiled libpq on Windows NT
> using MS Visual Studio 6.0. I followed the instructions
> given by Bob Kline <bkline@rksystems.com> in his mail from
> Fri, 3 Sep 1999.
> Unfortuanetely he sent his mail only to dbi-users, so I would
> like to repeat one major problem on this list.
> 
> Here is an excerpt from his mail:
> 
> 4. The DllMain function in src/interfaces/libpq/libpqdll.c of the
> PostgreSQL 6.5 sources, in which WSAStartup is invoked, is never called,
> which causes gethostbyname calls to fail.  Solution (more properly,
> "kludge" -- I know there's a cleaner fix somewhere, but this works for
> now): immediately after the local declarations for the connectDB function
> in src/interfaces/libpq/fe-connect.c:
> 
>#ifdef WIN32
>     static int WeHaveCalledWSAStartup;
> 
>     if (!WeHaveCalledWSAStartup) {
>         WSADATA wsaData;
>         if (WSAStartup(MAKEWORD(1, 1), &wsaData)) {
>             sprintf(conn->errorMessage,
>                     "WSAStartup failed: errno=%d\n", h_errno);
>             goto connect_errReturn;
>         }
>         WeHaveCalledWSAStartup = 1;
>     }
>#endif

You need not to take care wether WSAStartup is alredy called or not.
Windows handle it automatically.

---
Dmitry Samersoff, dms@wplus.net, ICQ:3161705
http://devnull.wplus.net
* There will come soft rains ...

Thu, 30 Sep 1999 15:43:37 +0400 (MSD)
Dmitry Samersoff <dms@wplus.net>
RE: [HACKERS] Win32=?KOI8-R?Q?_p=FCort?= of libpq
On Thu, 30 Sep 1999, Dmitry Samersoff wrote:

> 
> On 30-Sep-99 Edmund Mergl wrote:
> > Hi,
> > 
> > in the last few days I compiled libpq on Windows NT
> > using MS Visual Studio 6.0. I followed the instructions
> > given by Bob Kline <bkline@rksystems.com> in his mail from
> > Fri, 3 Sep 1999.
> > Unfortuanetely he sent his mail only to dbi-users, so I would
> > like to repeat one major problem on this list.
> > 
> > Here is an excerpt from his mail:
> > 
> > 4. The DllMain function in src/interfaces/libpq/libpqdll.c of the
> > PostgreSQL 6.5 sources, in which WSAStartup is invoked, is never called,
> > which causes gethostbyname calls to fail.  Solution (more properly,
> > "kludge" -- I know there's a cleaner fix somewhere, but this works for
> > now): immediately after the local declarations for the connectDB function
> > in src/interfaces/libpq/fe-connect.c:
> > 
> >#ifdef WIN32
> >     static int WeHaveCalledWSAStartup;
> > 
> >     if (!WeHaveCalledWSAStartup) {
> >         WSADATA wsaData;
> >         if (WSAStartup(MAKEWORD(1, 1), &wsaData)) {
> >             sprintf(conn->errorMessage,
> >                     "WSAStartup failed: errno=%d\n", h_errno);
> >             goto connect_errReturn;
> >         }
> >         WeHaveCalledWSAStartup = 1;
> >     }
> >#endif
> 
> You need not to take care wether WSAStartup is alredy called or not.
> Windows handle it automatically.

By calling it yourself you have more control over which minimum version 
will be loaded.

Vince.
-- 
==========================================================================
Vince Vielhaber -- KA8CSH   email: vev@michvhf.com   flame-mail: /dev/null
  # include <std/disclaimers.h>       Have you seen http://www.pop4.net?
        Online Campground Directory    http://www.camping-usa.com
       Online Giftshop Superstore    http://www.cloudninegifts.com
==========================================================================




Thu, 30 Sep 1999 08:06:31 -0400 (EDT)
Vince Vielhaber <vev@michvhf.com>
RE: [HACKERS] Win32=?KOI8-R?Q?_p=FCort?= of libpq

On 30-Sep-99 Vince Vielhaber wrote:
> On Thu, 30 Sep 1999, Dmitry Samersoff wrote:
> 
>> 
>> On 30-Sep-99 Edmund Mergl wrote:
>> > Hi,
>> > 
>> > in the last few days I compiled libpq on Windows NT
>> > using MS Visual Studio 6.0. I followed the instructions
>> > given by Bob Kline <bkline@rksystems.com> in his mail from
>> > Fri, 3 Sep 1999.
>> > Unfortuanetely he sent his mail only to dbi-users, so I would
>> > like to repeat one major problem on this list.
>> > 
>> > Here is an excerpt from his mail:
>> > 
>> > 4. The DllMain function in src/interfaces/libpq/libpqdll.c of the
>> > PostgreSQL 6.5 sources, in which WSAStartup is invoked, is never called,
>> > which causes gethostbyname calls to fail.  Solution (more properly,
>> > "kludge" -- I know there's a cleaner fix somewhere, but this works for
>> > now): immediately after the local declarations for the connectDB function
>> > in src/interfaces/libpq/fe-connect.c:
>> > 
>> >#ifdef WIN32
>> >     static int WeHaveCalledWSAStartup;
>> > 
>> >     if (!WeHaveCalledWSAStartup) {
>> >         WSADATA wsaData;
>> >         if (WSAStartup(MAKEWORD(1, 1), &wsaData)) {
>> >             sprintf(conn->errorMessage,
>> >                     "WSAStartup failed: errno=%d\n", h_errno);
>> >             goto connect_errReturn;
>> >         }
>> >         WeHaveCalledWSAStartup = 1;
>> >     }
>> >#endif
>> 
>> You need not to take care wether WSAStartup is alredy called or not.
>> Windows handle it automatically.
> 
> By calling it yourself you have more control over which minimum version 
> will be loaded.

Yes, but you can just call

   WSADATA wsaData;
   if (WSAStartup(MAKEWORD(1, 1), &wsaData)) {
            sprintf(conn->errorMessage,
                     "WSAStartup failed: errno=%d\n", h_errno);
            goto connect_errReturn;
   }


without WeHaveCalledWSAStartup at all.

---
Dmitry Samersoff, dms@wplus.net, ICQ:3161705
http://devnull.wplus.net
* There will come soft rains ...

Thu, 30 Sep 1999 16:52:04 +0400 (MSD)
Dmitry Samersoff <dms@wplus.net>
RE: [HACKERS] Win32=?KOI8-R?Q?_p=FCort?= of libpq
On Thu, 30 Sep 1999, Dmitry Samersoff wrote:

> 
> On 30-Sep-99 Vince Vielhaber wrote:
> > On Thu, 30 Sep 1999, Dmitry Samersoff wrote:
> > 
> >> 
> >> On 30-Sep-99 Edmund Mergl wrote:
> >> > Hi,
> >> > 
> >> > in the last few days I compiled libpq on Windows NT
> >> > using MS Visual Studio 6.0. I followed the instructions
> >> > given by Bob Kline <bkline@rksystems.com> in his mail from
> >> > Fri, 3 Sep 1999.
> >> > Unfortuanetely he sent his mail only to dbi-users, so I would
> >> > like to repeat one major problem on this list.
> >> > 
> >> > Here is an excerpt from his mail:
> >> > 
> >> > 4. The DllMain function in src/interfaces/libpq/libpqdll.c of the
> >> > PostgreSQL 6.5 sources, in which WSAStartup is invoked, is never called,
> >> > which causes gethostbyname calls to fail.  Solution (more properly,
> >> > "kludge" -- I know there's a cleaner fix somewhere, but this works for
> >> > now): immediately after the local declarations for the connectDB function
> >> > in src/interfaces/libpq/fe-connect.c:
> >> > 
> >> >#ifdef WIN32
> >> >     static int WeHaveCalledWSAStartup;
> >> > 
> >> >     if (!WeHaveCalledWSAStartup) {
> >> >         WSADATA wsaData;
> >> >         if (WSAStartup(MAKEWORD(1, 1), &wsaData)) {
> >> >             sprintf(conn->errorMessage,
> >> >                     "WSAStartup failed: errno=%d\n", h_errno);
> >> >             goto connect_errReturn;
> >> >         }
> >> >         WeHaveCalledWSAStartup = 1;
> >> >     }
> >> >#endif
> >> 
> >> You need not to take care wether WSAStartup is alredy called or not.
> >> Windows handle it automatically.
> > 
> > By calling it yourself you have more control over which minimum version 
> > will be loaded.
> 
> Yes, but you can just call
> 
>    WSADATA wsaData;
>    if (WSAStartup(MAKEWORD(1, 1), &wsaData)) {
>             sprintf(conn->errorMessage,
>                      "WSAStartup failed: errno=%d\n", h_errno);
>             goto connect_errReturn;
>    }
> 
> 
> without WeHaveCalledWSAStartup at all.

Accroding to the 1.1 spec, you must call WSACleanup() for EVERY WSAStartup
call made.  So if you call WSAStartup() three times, you must call
WSACleanup() three times - the first two only decrement the internal 
counter, the last one does the cleanup.  This may have changed in versions
of Winsock after 1.1 and my spec is a bit old (20 Jan 1993).

Vince.
-- 
==========================================================================
Vince Vielhaber -- KA8CSH   email: vev@michvhf.com   flame-mail: /dev/null
  # include <std/disclaimers.h>       Have you seen http://www.pop4.net?
        Online Campground Directory    http://www.camping-usa.com
       Online Giftshop Superstore    http://www.cloudninegifts.com
==========================================================================




Thu, 30 Sep 1999 12:09:46 -0400 (EDT)
Vince Vielhaber <vev@michvhf.com>
RE: [HACKERS] Win32=?KOI8-R?Q?_p=FCort?= of libpq