emersion / go-imap

📥 An IMAP library for clients and servers
MIT License
2.1k stars 296 forks source link

v1: Fix connection hang #615

Open doganpoyraz opened 7 months ago

doganpoyraz commented 7 months ago

This PR fixes the issue described in #611.

If the server does not respond to the Support calls in the New() function, the function blocks infinitely. Even if we supply a dialer with a timeout, there are 2 consequent Support calls. The first one runs with a deadline value but during the execution of the 2nd one, the deadline was set to the zero value. Setting the timeout value to the client is not enough because the client is not returned to the user yet.

I also added an optional timeout parameter to the DialWithDialer functions because callers may supply a Dialer that wraps the net.Dialer, which was our case.