Bug#947320: roundcube-core: Retry to connect to IMAP server

2019-12-27 Thread Sandro Knauß
Hi Guilhem,

> Did you try to upstream that patch?  Also FWIW the code snippet seems to
> be unchanged since <1.0.0, AFAICT no one complained so far so I'm unsure
> that Severity: important is really appropriate here, or if it's worth
> fixing in stable :-P

I know, that the code snipped is unchanged for a long time. I created that 
patch a long time ago. It is worth fixing it in stable, as it really can break 
things, if that patch is missing under specific circumstances. Last year I had 
a lot load on my IMAP Server, so the IMAP server was sometimes too slow to 
answer and that patch fixes that. 
Yes it should go upstream, but first I wanted to fix the Debian package ;P

hefee


signature.asc
Description: This is a digitally signed message part.


Bug#947320: roundcube-core: Retry to connect to IMAP server

2019-12-27 Thread Guilhem Moulin
Hi Sandro,

On Tue, 24 Dec 2019 at 17:21:40 +0100, Sandro Knauß wrote:
> An IMAP server may have temporally issues, like to much load and roundcube 
> fails with
> "Empty startup gretting".

Did you try to upstream that patch?  Also FWIW the code snippet seems to
be unchanged since <1.0.0, AFAICT no one complained so far so I'm unsure
that Severity: important is really appropriate here, or if it's worth
fixing in stable :-P

-- 
Guilhem.


signature.asc
Description: PGP signature


Bug#947320: roundcube-core: Retry to connect to IMAP server

2019-12-24 Thread Sandro Knauß
Package: roundcube-core
Version: 1.3.8+dfsg.1-2
Severity: important
Tags: patch

Hey,

An IMAP server may have temporally issues, like to much load and roundcube 
fails with
"Empty startup gretting".

Hefee


-- System Information:
Debian Release: bullseye/sid
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'stable-updates'), (500, 
'oldstable-updates'), (500, 'unstable'), (500, 'testing'), (500, 'stable'), 
(500, 'oldstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.3.0-3-amd64 (SMP w/4 CPU cores)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8), LANGUAGE=en_US 
(charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages roundcube-core depends on:
ii  dbconfig-common 2.0.13
ii  debconf [debconf-2.0]   1.5.73
ii  dpkg1.19.7
ii  libapache2-mod-php  2:7.3+69
ii  libapache2-mod-php7.3 [libapache2-mod-php]  7.3.12-1
pn  libjs-bootstrap4
ii  libjs-codemirror5.49.2-1
ii  libjs-jquery3.3.1~dfsg-3
pn  libjs-jquery-minicolors 
ii  libjs-jquery-ui 1.12.1+dfsg-5
pn  libjs-jstimezonedetect  
ii  libmagic1   1:5.37-6
pn  php-auth-sasl   
ii  php-cli 2:7.3+69
ii  php-common  2:69
pn  php-intl
pn  php-mail-mime   
pn  php-masterminds-html5   
pn  php-mbstring
pn  php-mcrypt  
pn  php-net-sieve   
pn  php-net-smtp
pn  php-net-socket  
ii  php-pear1:1.10.9+submodules+notgz-1
ii  php7.0-cli [php-cli]7.0.33-0+deb9u6
ii  php7.0-json [php-json]  7.0.33-0+deb9u6
ii  php7.2-cli [php-cli]7.2.9-1
ii  php7.2-json [php-json]  7.2.9-1
ii  php7.3-cli [php-cli]7.3.12-1
ii  php7.3-json [php-json]  7.3.12-1
pn  roundcube-mysql | roundcube-sqlite3 | roundcub  
ii  ucf 3.0038+nmu1

Versions of packages roundcube-core recommends:
ii  apache2 [httpd-cgi]  2.4.41-1
pn  php-gd   
pn  php-pspell   

Versions of packages roundcube-core suggests:
pn  php-crypt-gpg 
pn  php-mkopinsky-zxcvbn-php  
pn  php-net-ldap2 
pn  php-net-ldap3 
pn  roundcube-plugins 
Description: Retries to connect to IMAP server.
  As it may happen, that an IMAP server will have temporally issues and answers
  with "Empty startup greeting".
Author: Hefee 
Last-Update: 2019-12-24

---
--- a/program/lib/Roundcube/rcube_imap.php
+++ b/program/lib/Roundcube/rcube_imap.php
@@ -144,7 +144,11 @@ class rcube_imap extends rcube_storage
 
 $attempt = 0;
 do {
-$data = $this->plugins->exec_hook('storage_connect',
+if ($attempt > 0) {
+usleep(rand(1000, 10));
+}
+rcube::write_log('imap','Connecting to IMAP server 
attempt:'.$attempt);
+$data = $this->plugins->exec_hook('storage_connect',
 array_merge($this->options, array('host' => $host, 'user' => 
$user,
 'attempt' => ++$attempt)));
 
@@ -156,7 +160,7 @@ class rcube_imap extends rcube_storage
 rcube_utils::parse_socket_options($data['socket_options'], 
$data['host']);
 
 $this->conn->connect($data['host'], $data['user'], $pass, $data);
-} while(!$this->conn->connected() && $data['retry']);
+} while(!$this->conn->connected() && $data['attempt'] < 6);
 
 $config = array(
 'host' => $data['host'],