ok thanx:)
... here's the source ... can u tell me whats wrong? (the purpose of this
function is to allow for thread safety on the connection, and allow for
cancellation if the connection takes too long)
BTW ...
- coninfo is "host=localhost port=5432 dbname=testdb user=localuser
password=localpassword"
- I am using VC++ and compiling a windows execuatble ...
PGconn* PQconnectStartCS(const char* coninfo,LPCRITICAL_SECTION lpcs,bool*
lpcancel,int* lppge){
int& pge = *lppge;
bool& cancel = *lpcancel;
bool keepon = true;
PGconn* pr = 0;
pge = 0;
EnterCriticalSection(lpcs);
pr = PQconnectStart(coninfo);
while (!killthread(&cancel) && keepon){
switch(pge = PQconnectPoll(pr)){
case PGRES_POLLING_FAILED:
keepon = false;
break;
case PGRES_POLLING_OK:
pge = 0;
keepon = false;
break;
default:
break;
};
if (keepon)
Sleep(1);
};
LeaveCriticalSection(lpcs);
if (!pge && pr){
switch(pge = PQstatus(pr)){
case CONNECTION_OK:
pge = 0;
break;
};
};
return pr;
};
----- Original Message -----
From: "Tom Lane" <tgl@xxxxxxxxxxxxx>
To: "madhtr" <madhtr@xxxxxxxxx>
Cc: <pgsql-general@xxxxxxxxxxxxxx>
Sent: Tuesday, August 14, 2007 14:36
Subject: Re: pqlib in c++: PQconnectStart PQconnectPoll
"madhtr" <madhtr@xxxxxxxxx> writes:
when i intentioally try to connect asynchronously to a database that does
not exist, i get
"server closed the connection unexpectedly"
There's something wrong with your code then.
regards, tom lane
---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings
----- Original Message -----
From: "Tom Lane" <tgl@xxxxxxxxxxxxx>
To: "madhtr" <madhtr@xxxxxxxxx>
Cc: <pgsql-general@xxxxxxxxxxxxxx>
Sent: Tuesday, August 14, 2007 14:36
Subject: Re: pqlib in c++: PQconnectStart PQconnectPoll
"madhtr" <madhtr@xxxxxxxxx> writes:
when i intentioally try to connect asynchronously to a database that does
not exist, i get
"server closed the connection unexpectedly"
There's something wrong with your code then.
regards, tom lane
---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings
---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@xxxxxxxxxxxxxx so that your
message can get through to the mailing list cleanly