Re: [BUGS] WIN32 Non Blocking
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@candle.pha.pa.us>
To: "Darko Prenosil" <darko_prenosil@yahoo.com>
Cc: "PostgreSQL-Committers" <pgsql-committers@postgreSQL.org>
Sent: Friday, July 20, 2001 11:25 PM
Subject: Re: [BUGS] WIN32 Non BlockingHere 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 _snprintfHere 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@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
Import Notes
Reply to msg id not found: 00a101c1118b$76bba5a0$1700a8c0@darko