From 3faab0ca9e097627420aec19c01ad8336fe79c22 Mon Sep 17 00:00:00 2001
From: Marius Cramer <m.cramer@pixcept.de>
Date: Tue, 25 Feb 2014 03:01:22 -0500
Subject: [PATCH] Merge remote-tracking branch 'origin/stable-3.0.5'

---
 server/lib/classes/aps_installer.inc.php |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/server/lib/classes/aps_installer.inc.php b/server/lib/classes/aps_installer.inc.php
index 23c4b5f..089c7ab 100644
--- a/server/lib/classes/aps_installer.inc.php
+++ b/server/lib/classes/aps_installer.inc.php
@@ -371,6 +371,21 @@
 
 		$tmp = $app->db->queryOneRecord("SELECT value FROM aps_instances_settings WHERE name = 'main_database_login' AND instance_id = '".$app->db->quote($task['instance_id'])."';");
 		$newdb_login = $tmp['value'];
+		
+		/* Test if the new mysql connection is laready working to ensure that db servers in multiserver
+		   setups get enough time to create the database */
+		if($this->handle_type == 'install') {
+			for($n = 1; $n < 15; $n++) {
+				$link = mysql_connect($newdb_host, $newdb_login, $newdb_pw);
+				if (!$link) {
+					unset($link);
+					sleep(5);
+				} else {
+					unset($link);
+					break;
+				}
+			}
+		}
 
 		$this->putenv[] = 'DB_'.$db_id.'_TYPE=mysql';
 		$this->putenv[] = 'DB_'.$db_id.'_NAME='.$newdb_name;

--
Gitblit v1.9.1