From 0f1bc4bf0351dd8b284c7b4b69d350e61164b138 Mon Sep 17 00:00:00 2001
From: svncommit <devs@roundcube.net>
Date: Sun, 02 Oct 2005 11:01:44 -0400
Subject: [PATCH] 

---
 program/include/rcube_db.inc |   20 ++++++++--
 logs/errors                  |   57 ++++++++++++++++++++++++++++
 2 files changed, 73 insertions(+), 4 deletions(-)

diff --git a/logs/errors b/logs/errors
index 0a4efdf..e144b09 100644
--- a/logs/errors
+++ b/logs/errors
@@ -1034,3 +1034,60 @@
 [02-Oct-2005 12:38:13] PHP Notice:  Undefined index:  lowercase in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 1135
 [02-Oct-2005 12:38:13] PHP Notice:  Undefined index:  foot in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 107
 [02-Oct-2005 12:38:13] PHP Notice:  Undefined index:  foot in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 111
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  client_id in /usr/local/http-docs/admin/html/roundcubemail/program/include/main.inc on line 69
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  user_prefs in /usr/local/http-docs/admin/html/roundcubemail/program/include/main.inc on line 84
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  task in /usr/local/http-docs/admin/html/roundcubemail/program/include/main.inc on line 89
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  mbox in /usr/local/http-docs/admin/html/roundcubemail/program/include/main.inc on line 145
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  _framed in /usr/local/http-docs/admin/html/roundcubemail/index.php on line 86
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  _framed in /usr/local/http-docs/admin/html/roundcubemail/index.php on line 86
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  _framed in /usr/local/http-docs/admin/html/roundcubemail/program/include/main.inc on line 218
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  _framed in /usr/local/http-docs/admin/html/roundcubemail/program/include/main.inc on line 218
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  head in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 64
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined variable:  _auth in /usr/local/http-docs/admin/html/roundcubemail/index.php on line 135
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  user_id in /usr/local/http-docs/admin/html/roundcubemail/index.php on line 146
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  user_id in /usr/local/http-docs/admin/html/roundcubemail/index.php on line 158
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  user_id in /usr/local/http-docs/admin/html/roundcubemail/index.php on line 173
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  nr in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 1041
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  command in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 1044
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  vars in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 1114
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined variable:  a_replace_vars in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 1120
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  uppercase in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 1131
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  ucfirst in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 1131
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  uppercase in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 1133
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  lowercase in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 1135
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  nr in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 1041
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  command in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 1044
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  vars in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 1114
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined variable:  a_replace_vars in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 1120
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  uppercase in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 1131
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  ucfirst in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 1131
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  uppercase in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 1133
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  lowercase in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 1135
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  nr in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 1041
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  command in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 1044
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  vars in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 1114
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined variable:  a_replace_vars in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 1120
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  uppercase in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 1131
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  ucfirst in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 1131
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  uppercase in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 1133
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  lowercase in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 1135
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  type in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 710
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  newline in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 713
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  type in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 710
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  newline in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 713
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  _user in /usr/local/http-docs/admin/html/roundcubemail/program/include/main.inc on line 953
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined property:  name in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 645
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined property:  name in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 645
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined property:  name in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 645
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  host in /usr/local/http-docs/admin/html/roundcubemail/program/include/main.inc on line 973
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined variable:  form_host in /usr/local/http-docs/admin/html/roundcubemail/program/include/main.inc on line 999
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  nr in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 1041
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  command in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 1044
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  vars in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 1114
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined variable:  a_replace_vars in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 1120
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  uppercase in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 1131
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  ucfirst in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 1131
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  uppercase in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 1133
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  lowercase in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 1135
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  foot in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 107
+[02-Oct-2005 13:53:12] PHP Notice:  Undefined index:  foot in /usr/local/http-docs/admin/html/roundcubemail/program/include/rcube_shared.inc on line 111
diff --git a/program/include/rcube_db.inc b/program/include/rcube_db.inc
index f4dc222..87cb869 100755
--- a/program/include/rcube_db.inc
+++ b/program/include/rcube_db.inc
@@ -51,7 +51,9 @@
 	// Connect to specific database	
 	function dsn_connect($dsn)
 	{
-		$dbh = DB::connect($dsn);
+		// Use persistent connections if available
+		
+		$dbh = DB::connect($dsn, array('persistent' => $true));
 
 		if (DB::isError($dbh))
 			raise_error(array('code' => 500,
@@ -65,10 +67,20 @@
 	// Connect to appropiate databse	
 	function db_connect ($mode)
 	{
-		if ($this->db_connected && $this->db_mode=='w') return;
+		// Already connected
+		
+		if ($this->db_connected)
+			{
+			// no replication, current connection is ok
+			if ($this->db_dsnw==$this->db_dsnr) return;
+			
+			// connected to master, current connection is ok
+			if ($this->db_mode=='w') return;
 
-		if ($this->db_connected && $this->db_mode==$mode) return;
-
+			// Same mode, current connection is ok
+			if ($this->db_mode==$mode) return;
+			}
+			
 		if ($mode=='r')
 			$dsn=$this->db_dsnr;
 		else

--
Gitblit v1.9.1