[mapserver-commits] r9051 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Thu May 28 14:56:51 EDT 2009
Author: pramsey
Date: 2009-05-28 14:56:51 -0400 (Thu, 28 May 2009)
New Revision: 9051
Modified:
trunk/mapserver/HISTORY.TXT
trunk/mapserver/mappostgis.c
Log:
Test database connections before using them (#2932)
Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT 2009-05-28 17:58:26 UTC (rev 9050)
+++ trunk/mapserver/HISTORY.TXT 2009-05-28 18:56:51 UTC (rev 9051)
@@ -14,6 +14,8 @@
Current Version (SVN trunk):
----------------------------
+- Test database connections before using them (#2932)
+
- Support non-numeric join criteria (#2006)
- Ensure there's enough room in the SQL to hold a long (#1284)
Modified: trunk/mapserver/mappostgis.c
===================================================================
--- trunk/mapserver/mappostgis.c 2009-05-28 17:58:26 UTC (rev 9050)
+++ trunk/mapserver/mappostgis.c 2009-05-28 18:56:51 UTC (rev 9051)
@@ -1519,6 +1519,19 @@
/* Save this connection in the pool for later. */
msConnPoolRegister(layer, layerinfo->pgconn, msPostGISCloseConnection);
}
+ else {
+ /* Connection in the pool should be tested to see if backend is alive. */
+ if( PQstatus(layerinfo->pgconn) != CONNECTION_OK ) {
+ /* Uh oh, bad connection. Can we reset it? */
+ PQreset(layerinfo->pgconn);
+ if( PQstatus(layerinfo->pgconn) != CONNECTION_OK ) {
+ /* Nope, time to bail out. */
+ msSetError(MS_QUERYERR, "PostgreSQL database connection gone bad (%s)", "msPostGISLayerOpen()", PQerrorMessage(layerinfo->pgconn));
+ return MS_FAILURE;
+ }
+
+ }
+ }
/* Save the layerinfo in the layerObj. */
layer->layerinfo = (void*)layerinfo;
More information about the mapserver-commits
mailing list