Re: Connecting to a postgreSQL database with windows CE over wi-fi; failing gracefully - Mailing list pgsql-general

From Jasen Betts
Subject Re: Connecting to a postgreSQL database with windows CE over wi-fi; failing gracefully
Date
Msg-id gtel1p$ksp$4@reversiblemaps.ath.cx
Whole thread Raw
In response to Connecting to a postgreSQL database with windows CE over wi-fi; failing gracefully  (Peter Geoghegan <peter.geoghegan86@gmail.com>)
Responses Re: Re: Connecting to a postgreSQL database with windows CE over wi-fi; failing gracefully  (Peter Geoghegan <peter.geoghegan86@gmail.com>)
List pgsql-general
On 2009-04-29, Peter Geoghegan <peter.geoghegan86@gmail.com> wrote:
> Hello,
>
> I'm developing a PostgreSQL application for Windows CE 5 on a PDT/ PDA
> in C++/Qt, using Hiroshi Saito's libpq port for that platform. Since
> the connection is established over wi-fi, and wi-fi connectivity is
> often flaky, I feel that I have to "fail gracefully" to as great an
> extent as possible. The following utility function,
> VerifyDbConnection(), is called before every piece of database work:

such an approach is doomed to failure, you have just implemented a
race condition. what happens if the server becomes unavailable between
the request and the response, or during the response.

Also, test by pulling out the ethernet from the server to the switch.

when you shut the server down it announces this to the clients, it may
even ask their permission before proceeding.

> This seemed to work fine initially; I'd abruptly stop the database
> server, and I would see a messagebox informing me of a connectivity
> problem. Then, I'd start the server, click the retry button, and have
> connectivity restored. However, when I walk out of range of the wi-fi
> access point, which is the probable cause of losing connectivity in
> the real world, my program crashes without displaying an error message
> (I would expect to see a visual C++ runtime error message).

> Can someone suggest a reason for this, or a workaround?

you are not checking the return values from some of your libpq calls.

pgsql-general by date:

Previous
From: "Daniel Verite"
Date:
Subject: Re: Importing large objects from the client side programatically.
Next
From: Jasen Betts
Date:
Subject: Re: Any way to execute ad-hoc pl/pgsql?