Avoid deadlock in import and getaddrinfo. Fixes #349.