[PATCH] Improve NNTPconnect error reporting
Julien ÉLIE
julien at trigofacile.com
Sat Jun 5 08:15:43 UTC 2010
Hi Ian,
> In inn2 2.4.5, NNTPconnect does not always report errors very well.
I see that INN 2.5.2 has a similar behaviour.
> In the patch below I address this by always arranging for the buffer
> to contain a useful message.
The problem is that I cannot apply the patch. The whole code has changed
in INN 2.5.2.
> @@ -53,8 +64,11 @@ int NNTPconnect(char *host, int port, FILE **FromServerp, FILE **ToServerp, char
> hints.ai_family = PF_UNSPEC;
> hints.ai_socktype = SOCK_STREAM;
> sprintf(portbuf, "%d", port);
> - if (getaddrinfo(host, portbuf, &hints, &addr) != 0)
> + if ((gai_r = getaddrinfo(host, portbuf, &hints, &addr)) != 0) {
> + store_error(buff, "getaddrinfo failed: ", gai_strerror(gai_r));
> + errno = 0;
> return -1;
> + }
>
> for (ressave = addr; addr; addr = addr->ai_next) {
> if ((i = socket(addr->ai_family, addr->ai_socktype,
It is now driven in network_connect_host() in lib/network.c
/*
** Like network_connect, but takes a host and a port instead of an addrinfo
** struct list. Returns the file descriptor of the open socket on success,
** or -1 on failure. If getaddrinfo fails, errno may not be set to anything
** useful.
*/
and not directly in lib/remopen.c where we have:
fd = network_connect_host(host, port, NULL);
if (fd < 0)
return -1;
with no information from the getaddrinfo return code.
The network API (headers in include/inn/network.h) would then need to be
changed if we have to pass it a buffer to write the error.
Is it advisable to do that?
--
Julien ÉLIE
« Il était une fois un homme fidèle, c'est une belle histoire.
Il était une fois une femme fidèle, c'est un conte de fées. » (Maurice Jeanneret)
More information about the inn-workers
mailing list