Bug 3253

Summary: all addresses of getaddrinfo() result should be tried
Product: Claws Mail (GTK 2) Reporter: Timo Teräs <timo.teras>
Component: OtherAssignee: users
Status: RESOLVED FIXED    
Severity: normal    
Priority: P3    
Version: 3.10.1   
Hardware: PC   
OS: Linux   
Attachments:
Description Flags
Use getattrinfo instead of gethostbyname none

Description Timo Teräs 2014-08-21 07:31:50 UTC
If I have multiple A and/or AAAA records for hostname, only the first result returned by getaddrinfo() for which a socket can be created is tried. This means if that IP-address is not responsive (timeouts), the others are not tried.

E.g. imap.gmail.com has two A records, and one AAAA record. It has happened sometimes that the first A result timeouts, but the second A works. In these instances it is not possible to connect.
Comment 1 Andrej Kacian 2015-08-18 21:19:02 UTC
Created attachment 1559 [details]
Use getattrinfo instead of gethostbyname

Attached patch attempts to improve the situation by using getaddrinfo() instead of deprecated gethostbyname(), and trying each resolved address (skipping ipv6 addresses if ipv6 support is disabled).

Of course, review and testing needed, especially by people on ipv6.
Comment 2 users 2015-08-20 08:29:02 UTC
Changes related to this bug have been committed.
Please check latest Git and update the bug accordingly.
You can also get the patch from:
http://git.claws-mail.org/

++ ChangeLog	2015-08-20 08:29:02.732280727 +0200
http://git.claws-mail.org/?p=claws.git;a=commitdiff;h=99c3faf9573e885cac1fd625ce799d1f0acb6f04
Merge: d4741c3 8f4236e
Author: Colin Leroy <colin@colino.net>
Date:   Thu Aug 20 08:29:02 2015 +0200

    Merge branch 'master' of file:///home/git/claws

http://git.claws-mail.org/?p=claws.git;a=commitdiff;h=8f4236e282d3252ecf9f3920e2e5c312d2cf50fc
Author: Andrej Kacian <ticho@claws-mail.org>
Date:   Wed Oct 1 22:00:06 2014 +0200

    Use getaddrinfo() instead of gethostbyname() in socket.c.
    
    Closes bug #3253, as we're trying all resolved addresses.
    This should also make IPv6 work on Windows, bug #3495.
Comment 3 Ricardo Mones 2016-04-13 10:38:23 UTC
Fix already released in 3.13.0.