From 9d04d9fef9337cc365450a47dc3bedbb09e6d2bd Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Wed, 26 Mar 2014 15:32:09 +0100 Subject: [PATCH] Do not throw in postgis_datasource destruction if backend is down ... and persist_connections is true! Closes #2191 --- plugins/input/postgis/postgis_datasource.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/plugins/input/postgis/postgis_datasource.cpp b/plugins/input/postgis/postgis_datasource.cpp index cafcdeab8..39a89b540 100644 --- a/plugins/input/postgis/postgis_datasource.cpp +++ b/plugins/input/postgis/postgis_datasource.cpp @@ -445,10 +445,19 @@ postgis_datasource::~postgis_datasource() CnxPool_ptr pool = ConnectionManager::instance().getPool(creator_.id()); if (pool) { - shared_ptr conn = pool->borrowObject(); - if (conn) - { - conn->close(); + try { + shared_ptr conn = pool->borrowObject(); + if (conn) + { + conn->close(); + } + } catch (mapnik::datasource_exception const& ex) { + // happens when borrowObject tries to + // create a new connection and fails. + // In turn, new connection would be needed + // when our broke and was thus no good to + // be borrowed + // See https://github.com/mapnik/mapnik/issues/2191 } } }