Dear Cyrus developers,

`man imapd` explains `-T 0` should disable the reuse timeout:

> −T timeout
> 
> The number of seconds that the process will wait for a new connection before 
> shutting down. Note that a value of 0 (zero) will disable the timeout. The 
> default is 60.

But doing so results in crashes immediately after the first connection
with an arithmetic exception. Digging deeper, the issue is rather obvious:

    reuse_timeout = reuse_timeout + (rand() % reuse_timeout);

This should not be executed for `reuse_timeout == 0`. I attached a small
patch resolving the issue. `reuse_timeout = 0` results in disabled
alarms, probably this border case was overlooked when the random timeout
skew was added.

The patch is developed against Cyrus IMAP 2.5.7.

Regards from Lake Constance, Germany,
Jens Erat

-- 
Jens Erat
Universität Konstanz
Kommunikations-, Infomations-, Medienzentrum (KIM)
Abteilung Basisdienste
D-78457 Konstanz
Mail: jens.e...@uni-konstanz.de
385,386c385,387
<     /* pick a random timeout between reuse_timeout -> 2*reuse_timeout
<      * to avoid massive IO overload if the network connection goes away */
---
>     /* if timeout is enabled, pick a random timeout between reuse_timeout 
>      * and 2*reuse_timeout to avoid massive IO overload if the network
>      * connection goes away */
388c389,390
<     reuse_timeout = reuse_timeout + (rand() % reuse_timeout);
---
>     if (reuse_timeout)
>         reuse_timeout = reuse_timeout + (rand() % reuse_timeout);

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to