summaryrefslogtreecommitdiff
path: root/roundcubemail/program
diff options
context:
space:
mode:
authorsparc <sparc@208e9e7b-5314-0410-a742-e7e81cd9613c>2005-10-02 15:01:44 +0000
committersparc <sparc@208e9e7b-5314-0410-a742-e7e81cd9613c>2005-10-02 15:01:44 +0000
commit34a64b35fced015042411f1249e080883ed7239f (patch)
treee20e000ecb2e74ce8f98d13704a66e8d48addd43 /roundcubemail/program
parent80eff893c7869bae5112cc21273c8cd3df27bef8 (diff)
added use of persistent links and improved non-replication connection
git-svn-id: https://svn.roundcube.net/trunk@14 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'roundcubemail/program')
-rwxr-xr-xroundcubemail/program/include/rcube_db.inc20
1 files changed, 16 insertions, 4 deletions
diff --git a/roundcubemail/program/include/rcube_db.inc b/roundcubemail/program/include/rcube_db.inc
index f4dc222a5..87cb869f8 100755
--- a/roundcubemail/program/include/rcube_db.inc
+++ b/roundcubemail/program/include/rcube_db.inc
@@ -51,7 +51,9 @@ class rcube_db
// 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 @@ class rcube_db
// Connect to appropiate databse
function db_connect ($mode)
{
- if ($this->db_connected && $this->db_mode=='w') return;
-
- if ($this->db_connected && $this->db_mode==$mode) 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;
+ // Same mode, current connection is ok
+ if ($this->db_mode==$mode) return;
+ }
+
if ($mode=='r')
$dsn=$this->db_dsnr;
else