Skip to content

Prevent deadlock in IMAPServer.close when using 'maxsyncaccounts' and 'maxconnections'.#241

Merged
thekix merged 1 commit into
OfflineIMAP:masterfrom
altruizine:upstream-deadlock-fix
Jun 8, 2026
Merged

Prevent deadlock in IMAPServer.close when using 'maxsyncaccounts' and 'maxconnections'.#241
thekix merged 1 commit into
OfflineIMAP:masterfrom
altruizine:upstream-deadlock-fix

Conversation

@altruizine

Copy link
Copy Markdown
Contributor

We introduce a separate closing flag that's checked in acquireconnection, decoupling the connectionlock from the semaphore such that they can be acquired separately.

This is work towards getting rid of the 'maxsyncaccounts' / 'maxconnections' deprecation warning in the manual.

This PR

  • I've read the DCO.
  • I've read the Coding Guidelines
  • The relevant informations about the changes stands in the commit message, not here in the message of the pull request.
  • Code changes follow the style of the files they change.
  • Code is tested (details below).

References

Additional information

I'm using this change in production with 'maxsyncaccounts' and 'maxconnections' both set to values > 1, as well as with autorefresh set. This change allows recovery from connection hangs after network changes (such as resuming after system suspend).

… 'maxconnections'.

We introduce a separate closing flag that's checked in
acquireconnection, decoupling the connectionlock from the semaphore
such that they can be acquired separately.

Signed-off-by: Michael Hohmuth <hohmuth@sax.de>
@thekix

thekix commented Apr 25, 2026

Copy link
Copy Markdown
Member

PR to testing. Please, check it :-)

Thanks!

@altruizine

Copy link
Copy Markdown
Contributor Author

I'll run the testing branch for a day or two and report back. Thanks!

@altruizine

Copy link
Copy Markdown
Contributor Author

The fix works fine on the testing branch but surfaces an issue with the new mechanism that attempts to fix unhealthy sockets. I'm proposing a new solution (tested, works for me) in #243.

@thekix thekix added the testing Issue included in branch "testing" label May 16, 2026
@thekix thekix merged commit d16afe5 into OfflineIMAP:master Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing Issue included in branch "testing"

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants