mirror of
https://github.com/mjl-/mox.git
synced 2025-06-28 11:38:16 +03:00
imapserver: Prevent spurious test failures due to compression layer being closed and TLS close-writes failing
This commit is contained in:
parent
062c3ac182
commit
9c40205343
@ -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.
|
// 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
|
// You may want to call Logout first. Closing a connection with a mailbox with
|
||||||
// deleted messages not yet expunged will not expunge those messages.
|
// 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) {
|
func (c *Conn) Close() (rerr error) {
|
||||||
defer c.recover(&rerr)
|
defer c.recover(&rerr)
|
||||||
|
|
||||||
|
@ -40,6 +40,11 @@ func TestCompressStartTLS(t *testing.T) {
|
|||||||
tc.transactf("ok", "append inbox (\\seen) {%d+}\r\n%s", len(exampleMsg), exampleMsg)
|
tc.transactf("ok", "append inbox (\\seen) {%d+}\r\n%s", len(exampleMsg), exampleMsg)
|
||||||
tc.transactf("ok", "noop")
|
tc.transactf("ok", "noop")
|
||||||
tc.transactf("ok", "fetch 1 body.peek[1]")
|
tc.transactf("ok", "fetch 1 body.peek[1]")
|
||||||
|
|
||||||
|
// Prevent client.Close from failing the test. The client first closes the
|
||||||
|
// compression stream, which causes the server to close the connection, after which
|
||||||
|
// the messages to close the TLS connection are written to a closed socket.
|
||||||
|
tc.client.SetPanic(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCompressBreak(t *testing.T) {
|
func TestCompressBreak(t *testing.T) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user