imapserver: Prevent spurious test failures due to compression layer being closed and TLS close-writes failing

This commit is contained in:
Mechiel Lukkien
2025-02-26 15:41:46 +01:00
parent 062c3ac182
commit 9c40205343
2 changed files with 15 additions and 0 deletions

View File

@ -170,10 +170,20 @@ func (c *Conn) xflush() {
}
}
// SetPanic sets whether errors cause a panic instead of returning errors.
func (c *Conn) SetPanic(panic bool) {
c.panic = panic
}
// Close closes the connection, flushing and closing any compression and TLS layer.
//
// You may want to call Logout first. Closing a connection with a mailbox with
// deleted messages not yet expunged will not expunge those messages.
//
// Closing a TLS connection that is logged out, or closing a TLS connection with
// compression enabled (i.e. two layered streams), may cause spurious errors
// because the server may immediate close the underlying connection when it sees
// the connection is being closed.
func (c *Conn) Close() (rerr error) {
defer c.recover(&rerr)