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-Committers <pgsql-committers(at)postgreSQL(dot)org>
Subject: Re: [BUGS] WIN32 Non Blocking
Date: 2001-07-20 21:25:45
Message-ID: 200107202125.f6KLPjx19548@candle.pha.pa.us (view raw or flat)
Thread:
Lists: 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(at)candle(dot)pha(dot)pa(dot)us>
> To: "Darko Prenosil" <darko_prenosil(at)yahoo(dot)com>
> Cc: <pgsql-bugs(at)postgresql(dot)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(dot)Prenosil(at)finteh(dot)hr
> 
> 
> 
> 
> _________________________________________________________
> 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-committers by date

Next:From: Tom LaneDate: 2001-07-20 21:42:27
Subject: Re: pgsql/src/interfaces/libpq fe-connect.c fe-exe ...h
Previous:From: Bruce MomjianDate: 2001-07-20 21:08:39
Subject: Re: pgsql/src/interfaces/libpq fe-connect.c fe-exe ...h

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