Re: libpq sockets on win32 - Mailing list pgsql-interfaces

From Bruce Momjian
Subject Re: libpq sockets on win32
Date
Msg-id 200106041822.f54IMjY29512@candle.pha.pa.us
Whole thread Raw
In response to libpq sockets on win32  ("Jeff Johnson" <jeff@jeffjohnson.net>)
List pgsql-interfaces
Can you try this patch and let me know if it helps?  It is a different
approach.  This was the only place I saw errno checked for a
non-predefined value.

One other solution may be to use the #define only in the libpq C files
that need it.  What really stinks is that the errno define is only
useful for socket errno settings.

I do see a use in fe-connect.c:

    #ifndef WIN32
            if (errno == EINPROGRESS || errno == 0)
    #else
            if (WSAGetLastError() == WSAEINPROGRESS)
    #endif

I hate to litter this through the whole source.  I wonder if we have to
bracket the errno checkes with #define/#undef.  Can you try that with
the fix described on the web page.  The above would convert to:

    #ifdef WIN32
    #define errno WSAGetLastError
    #endif
            if (errno == EINPROGRESS || errno == 0)
    #ifdef WIN32
    #undef errno
    #endif

Maybe make these into their own macros somehow.

> > > This article describes the problem and work around.
> > > http://msdn.microsoft.com/library/psdk/winsock/ovrvw3_26ia.htm
> >
> > I can't read that web site under Netscape.
> >
> > If I could read it, I think I could fix it.  Please send it in some
> > readable format.
> >
>
> I chopped the content out and stuck it into a basic HTML file and
> attached it.
>
> Thanks for taking a look,
> Jeff

[ Attachment, skipping... ]

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
Index: src/interfaces/libpq/fe-misc.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v
retrieving revision 1.49
diff -c -r1.49 fe-misc.c
*** src/interfaces/libpq/fe-misc.c    2001/05/28 15:29:51    1.49
--- src/interfaces/libpq/fe-misc.c    2001/06/04 17:52:40
***************
*** 614,619 ****
--- 614,623 ----

          int            sent;

+ #ifdef WIN32
+         errno = 0;    /* Win32 doesn't set this, needs reset */
+ #endif
+
  #ifdef USE_SSL
          if (conn->ssl)
              sent = SSL_write(conn->ssl, ptr, len);

pgsql-interfaces by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: libpq sockets on win32
Next
From: "Jeff Johnson"
Date:
Subject: RE: libpq sockets on win32