gnutls-cli should handle network errors more gracefully
Mantas Mikulėnas
grawity at gmail.com
Mon Nov 26 23:18:23 CET 2012
On 2012-11-26 23:26, Nikos Mavrogiannopoulos wrote:
> On 11/26/2012 08:54 PM, Mantas Mikulėnas wrote:
>
>> On Mon, Nov 26, 2012 at 8:44 PM, Nikos Mavrogiannopoulos
>> <nmav at gnutls.org> wrote:
>>> On Sun, Nov 25, 2012 at 10:10 PM, Mantas Mikulėnas <grawity at gmail.com> wrote:
>>>
>>>>>> The expected result here is that `gnutls-cli` would keep trying other
>>>>>> addresses returned from getaddrinfo(), until at least one succeeds.
>>>>>
>>>>>
>>>>> I'm curious, how do other networking programs avoid this issue? Do they
>>>>> keep trying or do they provide an option to force IPv4 or 6?
>>>>
>>>> The ones I just tested – `lftp`, `curl`, `nc-openbsd`, `mutt`, `ncat`,
>>>> `wget`, inetutils `telnet` and `ssh` – keep trying addresses until one
>>>> succeeds, or until the program runs out of addresses to try.
>>>
>>> Hello,
>>> Could you try this patch and verify that it works in your use case?
>>> http://git.savannah.gnu.org/gitweb/?p=gnutls.git;a=commitdiff;h=5da62fb671474b1ffaad5dd3062895ca109c47bf
>>>
>>> regards,
>>> Nikos
>>
>> The patch doesn't change anything; `gnutls-cli` still exit(1)'s after
>> the first error and does not attempt other addresses. (Also,
>> `gnutls-cli` now only shows the hostname, while previously it used to
>> show the actual IP address it tried.)
>
>
> Well, since you have the test environment could you provide a patch for
> that to work as expected? Is replacing the exit() with continue, enough?
Just tried it – yes, changing "exit(1)" to "continue" seems to be enough.
In both "Connecting..." and "Cannot connect..." printfs, replacing
'hostname' with 'buffer' also fixes the issue with IP addresses not
being displayed.
diff --git a/src/socket.c b/src/socket.c
index f901482..9a2ce10 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -176,14 +176,14 @@ socket_open (socket_st * hd, const char *hostname,
const char *service, int udp)
}
- printf ("Connecting to '%s:%s'...\n", hostname, portname);
+ printf ("Connecting to [%s]:%s...\n", buffer, portname);
err = connect (sd, ptr->ai_addr, ptr->ai_addrlen);
if (err < 0)
{
- fprintf (stderr, "Cannot connect to %s:%s: %s\n", hostname,
+ fprintf (stderr, "Cannot connect to [%s]:%s: %s\n", buffer,
portname, strerror (errno));
- exit (1);
+ continue;
}
break;
}
--
Mantas Mikulėnas <grawity at gmail.com>
More information about the Gnutls-devel
mailing list