Skip site navigation (1) Skip section navigation (2)

Re: [BUGS] WIN32 Non Blocking

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Darko Prenosil <darko_prenosil(at)yahoo(dot)com>
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: [BUGS] WIN32 Non Blocking
Date: 2001-07-21 04:33:43
Message-ID: 200107210433.f6L4Xhi05782@candle.pha.pa.us (view raw or flat)
Thread:
Lists: pgsql-patches
OK, there appears to be heavy demand for this patch so I am applying it
right away.  I also made the win32.h change you suggested.  This fixes
the _snprintf undefined error reported a few hours ago.  Not sure why
the elog() problem is appearing.

> 
> ----- Original Message -----
> From: "Bruce Momjian" <pgman(at)candle(dot)pha(dot)pa(dot)us>
> To: "Darko Prenosil" <darko_prenosil(at)yahoo(dot)com>
> Cc: "PostgreSQL-Committers" <pgsql-committers(at)postgreSQL(dot)org>
> Sent: Friday, July 20, 2001 11:25 PM
> Subject: Re: [BUGS] WIN32 Non Blocking
> 
> 
> >
> > Here is the email I received that made me apply the Win32 libpq patch. I
> > asked him to send me a diff showing exactly what he wants added.  By
> > committing to CVS, perhaps he can diff against the current cvs tree.
> >
> > >
> 
> Hi Bruce !
> I downloaded new source for lib (only few hours old !!!), and made changes
> on
> this new source
> to make non-blocking connection work.
> I tested it, and PQSendQuery and PQGetResult are working fine.
> 
> In win32.h I added one line:
> #define snprintf _snprintf
> 
> 
> Here is new diff for fe-connect.c
> 
> *** fe-connect.c Sat Jul 21 02:12:35 2001
> --- fe-connect-new.c Sat Jul 21 03:16:51 2001
> ***************
> *** 70,76 ****
> 
>   #define NOTIFYLIST_INITIAL_SIZE 10
>   #define NOTIFYLIST_GROWBY 10
> !
> 
>   /* ----------
>    * Definition of the conninfo parameters and their fallback resources.
> --- 70,76 ----
> 
>   #define NOTIFYLIST_INITIAL_SIZE 10
>   #define NOTIFYLIST_GROWBY 10
> ! #define WIN32_NON_BLOCKING_CONNECTIONS
> 
>   /* ----------
>    * Definition of the conninfo parameters and their fallback resources.
> ***************
> *** 932,940 ****
> --- 932,946 ----
>     * Thus, we have make arrangements for all eventualities.
>     * ----------
>     */
> + #ifndef WIN32
>    if (connect(conn->sock, &conn->raddr.sa, conn->raddr_len) < 0)
>    {
>     if (errno == EINPROGRESS || errno == 0)
> + #else
> +  if (connect(conn->sock, &conn->raddr.sa, conn->raddr_len) != 0)
> +  {
> +   if (errno == EINPROGRESS || errno == EWOULDBLOCK)
> + #endif
>     {
> 
>      /*
> ***************
> *** 1208,1222 ****
>      {
>       ACCEPT_TYPE_ARG3 laddrlen;
> 
> - #ifndef WIN32
> -     int   optval;
> -
> - #else
> -     char  optval;
> -
> - #endif
> -     ACCEPT_TYPE_ARG3 optlen = sizeof(optval);
> -
>       /*
>        * Write ready, since we've made it here, so the
>        * connection has been made.
> --- 1214,1219 ----
> ***************
> *** 1227,1232 ****
> --- 1224,1233 ----
>        * state waiting for us on the socket.
>        */
> 
> + #ifndef WIN32
> +     int   optval;
> +     ACCEPT_TYPE_ARG3 optlen = sizeof(optval);
> +
>       if (getsockopt(conn->sock, SOL_SOCKET, SO_ERROR,
>             (char *) &optval, &optlen) == -1)
>       {
> ***************
> *** 1246,1251 ****
> --- 1247,1265 ----
>        connectFailureMessage(conn, optval);
>        goto error_return;
>       }
> + #else
> +     char far  optval[8];
> +     ACCEPT_TYPE_ARG3 optlen = sizeof(optval);
> +
> +     int OptResult=getsockopt(conn->sock, SOL_SOCKET, SO_ERROR,optval,
> &optlen);
> +     if (OptResult==SOCKET_ERROR){
> +      printfPQExpBuffer(&conn->errorMessage,
> +           "PQconnectPoll() -- getsockopt() failed: "
> +            "errno=%i\n", errno);
> +      connectFailureMessage(conn, OptResult);
> +      goto error_return;
> +     }
> + #endif
> 
>       /* Fill in the client address */
>       laddrlen = sizeof(conn->laddr);
> 
> 
> 
> 
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
> 
> 

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman(at)candle(dot)pha(dot)pa(dot)us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

pgsql-patches by date

Next:From: Rene PijlmanDate: 2001-07-21 15:21:33
Subject: Improvement Linux startup script
Previous:From: Bruce Momjian - CVSDate: 2001-07-21 04:32:42
Subject: pgsql/src/interfaces/libpq fe-connect.c win32.h

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group