From 4a63f1efaff83dd03e663ed1a432a15dc0100be3 Mon Sep 17 00:00:00 2001 From: alecpl <alec@alec.pl> Date: Mon, 07 Sep 2009 03:53:01 -0400 Subject: [PATCH] - Fix roundcube hangs on empty inbox with bincimapd (#1486093) --- program/include/rcube_imap.php | 39 +++++++++++++++++++++------------------ 1 files changed, 21 insertions(+), 18 deletions(-) diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php index b271245..f172931 100644 --- a/program/include/rcube_imap.php +++ b/program/include/rcube_imap.php @@ -36,7 +36,7 @@ * * @package Mail * @author Thomas Bruederli <roundcube@gmail.com> - * @version 1.40 + * @version 1.5 * @link http://ilohamail.org */ class rcube_imap @@ -107,16 +107,20 @@ raise_error(array('code' => 403, 'type' => 'imap', 'file' => __FILE__, 'message' => 'Open SSL not available;'), TRUE, FALSE); $port = 143; - } + } $ICL_PORT = $port; $IMAP_USE_INTERNAL_DATE = false; - $data = rcmail::get_instance()->plugins->exec_hook('imap_connect', array('host' => $host, 'user' => $user)); - if (!empty($data['pass'])) - $pass = $data['pass']; + $attempt = 0; + do { + $data = rcmail::get_instance()->plugins->exec_hook('imap_connect', array('host' => $host, 'user' => $user, 'attempt' => ++$attempt)); + if (!empty($data['pass'])) + $pass = $data['pass']; - $this->conn = iil_Connect($data['host'], $data['user'], $pass, $this->options); + $this->conn = iil_Connect($data['host'], $data['user'], $pass, $this->options); + } while(!$this->conn && $data['retry']); + $this->host = $data['host']; $this->user = $data['user']; $this->pass = $pass; @@ -609,7 +613,7 @@ else { $a_index = iil_C_FetchHeaderIndex($this->conn, $mailbox, "1:*", $this->sort_field, $this->skip_deleted); - + if (empty($a_index)) return array(); @@ -2224,8 +2228,10 @@ $msg_count = $this->_messagecount($mailbox); $cache_count = count($cache_index); - // console("Cache check: $msg_count !== ".count($cache_index)); - + // empty mailbox + if (!$msg_count) + return $cache_count ? -2 : 1; + if ($cache_count==$msg_count) { if ($this->skip_deleted) { $h_index = iil_C_FetchHeaderIndex($this->conn, $mailbox, "1:*", 'UID', $this->skip_deleted); @@ -2886,7 +2892,7 @@ private function _change_subscription($a_mboxes, $mode) { $updated = FALSE; - + if (is_array($a_mboxes)) foreach ($a_mboxes as $i => $mbox_name) { @@ -2894,15 +2900,12 @@ $a_mboxes[$i] = $mailbox; if ($mode=='subscribe') - $result = iil_C_Subscribe($this->conn, $mailbox); + $updated = iil_C_Subscribe($this->conn, $mailbox); else if ($mode=='unsubscribe') - $result = iil_C_UnSubscribe($this->conn, $mailbox); - - if ($result>=0) - $updated = TRUE; + $updated = iil_C_UnSubscribe($this->conn, $mailbox); } - - // get cached mailbox list + + // get cached mailbox list if ($updated) { $a_mailbox_cache = $this->get_cache('mailboxes'); @@ -2914,7 +2917,7 @@ $a_mailbox_cache = array_merge($a_mailbox_cache, $a_mboxes); else if ($mode=='unsubscribe') $a_mailbox_cache = array_diff($a_mailbox_cache, $a_mboxes); - + // write mailboxlist to cache $this->update_cache('mailboxes', $this->_sort_mailbox_list($a_mailbox_cache)); } -- Gitblit v1.9.1