From e78ab767d3f3415ee32c5c703bb1db8c39782aa5 Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@musicpd.org>
Date: Mon, 23 Jan 2017 18:48:04 +0100
Subject: [PATCH] db/proxy: make connect errors during startup non-fatal

---
 NEWS                                   |  1 +
 src/db/plugins/ProxyDatabasePlugin.cxx | 10 ++++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index 9f2f8a03c..df9aecde6 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ ver 0.20.3 (not yet released)
   - "playlistadd" creates new playlist if it does not exist, as documented
 * database
   - proxy: fix error "terminate called after throwing ..."
+  - proxy: make connect errors during startup non-fatal
 * replay gain: don't reset ReplayGain levels when unpausing playback
 * silence surround channels when converting from stereo
 * use shortcuts such as "dsd64" in log messages
diff --git a/src/db/plugins/ProxyDatabasePlugin.cxx b/src/db/plugins/ProxyDatabasePlugin.cxx
index 983c0a704..5c505a835 100644
--- a/src/db/plugins/ProxyDatabasePlugin.cxx
+++ b/src/db/plugins/ProxyDatabasePlugin.cxx
@@ -346,9 +346,15 @@ ProxyDatabase::Create(EventLoop &loop, DatabaseListener &listener,
 void
 ProxyDatabase::Open()
 {
-	Connect();
-
 	update_stamp = 0;
+
+	try {
+		Connect();
+	} catch (const std::runtime_error &error) {
+		/* this error is non-fatal, because this plugin will
+		   attempt to reconnect again automatically */
+		LogError(error);
+	}
 }
 
 void