Re: [BUGS] WIN32 Non Blocking - Mailing list pgsql-committers

From Bruce Momjian
Subject Re: [BUGS] WIN32 Non Blocking
Date
Msg-id 200107202125.f6KLPjx19548@candle.pha.pa.us
Whole thread Raw
List pgsql-committers
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.

>
> ----- Original Message -----
> From: "Bruce Momjian" <pgman@candle.pha.pa.us>
> To: "Darko Prenosil" <darko_prenosil@yahoo.com>
> Cc: <pgsql-bugs@postgresql.org>
> Sent: Tuesday, July 17, 2001 2:51 PM
> Subject: Re: [BUGS] WIN32 Non Blocking
>
>
> >
> > I just got a new Win32 libpq patch.  Please see it at:
> >
> > http://candle.pha.pa.us/cgi-bin/pgpatches
> >
> > How does your match with that one?  I haven't applied it yet.
> >
> >
>
>
> Hi Bruce!
>
> First I'm sorry for being lazy and not giving You the answer when You asked.
>  I did take a look at the patch that Dmitry Yurtaev posted.
> He's code is looking better than my in getting error information, I only
> forced it to work.
> Dmitry also corrected problem with "EWOULDBLOCK" status, so you can skip
> this too in my code.
> So if You accept Dmitry's code only one more thing should be done
> to make non-blocking connections:
>
> Correct the PQconnectPoll function, because WINSOCK getsockopt
> function must be called in different way under WIN32 !
>
> Here is code :
>
>     /*
>      * Now check (using getsockopt) that there is not an error
>      * 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){
>      printfPQExpBuffer(&conn->errorMessage,
>           "PQconnectPoll() -- getsockopt() failed: "
>            "errno=%d\n%s\n",
>            errno, strerror(errno));
>      goto error_return;
>     }
>     else if (optval != 0)
>     {
>
>      /*
>       * When using a nonblocking connect, we will typically
>       * see connect failures at this point, so provide a
>       * friendly error message.
>       */
>      connectFailureMessage(conn, "PQconnectPoll()", 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",
>            WSAGetLastError());
>      connectFailureMessage(conn, "PQconnectPoll()", OptResult);
>      goto error_return;
>     }
> #endif
>
> ...................Or something like that
>
>
> Documentation on getsockopt function I found in MSDN, if you need it , I'll
> send it to You.
>
> I'm new in Linux world, so please forgive me that I made diff that shows
> irrelevant code changes like
> spaces between comments.
>
> Darko Prenosil
> Darko.Prenosil@finteh.hr
>
>
>
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>
>

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

pgsql-committers by date:

Previous
From: Bruce Momjian - CVS
Date:
Subject: pgsql/doc TODO
Next
From: Bruce Momjian
Date:
Subject: Re: pgsql/src/interfaces/libpq fe-connect.c fe-exe ...h