Received: from wm.hub.org (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 7397D9FB1F5 for ; Mon, 30 Oct 2006 00:32:38 -0400 (AST) Received: from maia (wm.hub.org [200.46.204.128]) by wm.hub.org (Postfix) with ESMTP id 6A7A7DFA145 for ; Mon, 30 Oct 2006 04:32:38 +0000 (UTC) X-Greylist: delayed 00:05:01.836082 by SQLgrey- Received: from mout.perfora.net (mout.perfora.net [217.160.230.40]) by postgresql.org (Postfix) with ESMTP id F0F1D9FA350 for ; Wed, 11 Oct 2006 13:17:05 -0300 (ADT) Received: from [67.47.181.157] (helo=204.115.98.10) by mrelay.perfora.net (node=mrelayus1) with ESMTP (Nemesis), id 0MKp2t-1GXggR36jC-0000pL; Wed, 11 Oct 2006 12:12:02 -0400 From: Terry Lee Tucker Organization: Turbo Logistics To: pgsql-interfaces@postgresql.org Subject: Re: libpq - check PGconn* - is it valid Date: Wed, 11 Oct 2006 12:11:07 -0400 User-Agent: KMail/1.5.3 References: <95520488.20061011183313@apriorit.com> In-Reply-To: <95520488.20061011183313@apriorit.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200610111211.07614.terry@leetuckert.net> X-Provags-ID: perfora.net abuse@perfora.net login:1a2cd3a8d27ba7338886b6f6e621c962 X-Archive-Number: 200610/31 X-Sequence-Number: 6314 On Wednesday 11 October 2006 11:33 am, Dmitriy Chumack thus communicated: > Hi everyone. > > I have such a problem. My application, some server, use libpq librarry > to interact with PostgreSQL-8.1.0 database. Postgresql server and my > server work on different computers in the local network. When my server > starts, it creates pool of 10 connections to database. My server use > PQexec() to submit queries to db. But when there is no network > connection to the database (I simply unplug the network cable from > computer on which PG server is run) and my server calls PQexec() - > than it hangs in PQexec() call. And it will hang there for a very > long time (I wait about 30 minutes and there is no result). And > when I plug in the network cable back, PQexec() remains hanging (I > wait about 10 minutes and there is no result too). > > I use simply (not ssl) connection to db. > > So how can I check PGconn pointer if it represent a health connection > to prevent my server to hang in PQexec() call? > > Thanks in advance. Use: ConnStatusType PQstatus(const PGconn *conn); See the docs for details. -- Terry Lee Tucker Turbo's IT Manager Turbo, division of Ozburn-Hessey Logistics 2251 Jesse Jewell Pkwy NE Gainesville, GA 30501 Tel: (336) 372-6812 Fax: (336) 372-6812 Cell: (336) 363-4719 terry@turbocorp.com www.turbocorp.com