diff options
author | Thomas Bruederli <thomas@roundcube.net> | 2014-01-21 17:18:28 +0100 |
---|---|---|
committer | Thomas Bruederli <thomas@roundcube.net> | 2014-01-21 17:18:28 +0100 |
commit | d93ce5cde23b7170b96fd9816e8d5e8cfdf6e0f6 (patch) | |
tree | 6bd4d9dd3584eddd5b86ffa7f8a7182695e1d451 /program | |
parent | 19262e6eab19951393154d8e52fe141c63b5cd5d (diff) |
Fix concurrent connections to IMAP while searching
Diffstat (limited to 'program')
-rw-r--r-- | program/lib/Roundcube/rcube_imap_search.php | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/program/lib/Roundcube/rcube_imap_search.php b/program/lib/Roundcube/rcube_imap_search.php index 70a11bc1c..c88198140 100644 --- a/program/lib/Roundcube/rcube_imap_search.php +++ b/program/lib/Roundcube/rcube_imap_search.php @@ -189,6 +189,8 @@ class rcube_imap_search_job extends Stackable $imap = $this->worker->get_imap(); if (!$imap->connected()) { + trigger_error("No IMAP connection for $this->folder", E_USER_WARNING); + if ($this->threading) { return new rcube_result_thread(); } @@ -280,14 +282,13 @@ class rcube_imap_search_worker extends Worker public $options; private $conn; + private $counts = 0; /** * Default constructor */ public function __construct($id, $options) { - $options['ident']['command'] = 'search-'.$id; - $this->id = $id; $this->options = $options; } @@ -298,21 +299,19 @@ class rcube_imap_search_worker extends Worker public function get_imap() { // TODO: make this connection persistent for several jobs - #if ($this->conn) - # return $this->conn; + // This doesn't seem to work. Socket connections don't survive serialization which is used in pthreads $conn = new rcube_imap_generic(); # $conn->setDebug(true, function($conn, $message){ trigger_error($message, E_USER_NOTICE); }); if ($this->options['user'] && $this->options['password']) { - // TODO: do this synchronized to avoid warnings like "Only one Id allowed in non-authenticated state" + $this->options['ident']['command'] = 'search-' . $this->id . 't' . ++$this->counts; $conn->connect($this->options['host'], $this->options['user'], $this->options['password'], $this->options); } if ($conn->error) trigger_error($conn->error, E_USER_WARNING); - #$this->conn = $conn; return $conn; } |