1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-11-10 21:38:50 +01:00

* http.c (connect_server): Differentiate between generic "can't connect"

errors and the more specific "host not found". Suggested by Samuel
Tardieu.
This commit is contained in:
David Shaw 2003-11-01 14:27:10 +00:00
parent 5c37fd90bf
commit 9a69b07bd7
2 changed files with 18 additions and 4 deletions

View File

@ -1,3 +1,9 @@
2003-11-01 David Shaw <dshaw@jabberwocky.com>
* http.c (connect_server): Differentiate between generic "can't
connect" errors and the more specific "host not found". Suggested
by Samuel Tardieu.
2003-10-29 Werner Koch <wk@gnupg.org>
* miscutil.c (answer_is_okay_cancel): New.

View File

@ -710,7 +710,7 @@ start_server()
static int
connect_server( const char *server, ushort port, unsigned int flags )
{
int sock=-1,srv,srvcount=0,connected=0;
int sock=-1,srv,srvcount=0,connected=0,hostfound=0;
struct srventry *srvlist=NULL;
#ifdef _WIN32
@ -778,7 +778,9 @@ connect_server( const char *server, ushort port, unsigned int flags )
sprintf(portstr,"%u",srvlist[srv].port);
memset(&hints,0,sizeof(hints));
hints.ai_socktype=SOCK_STREAM;
if(getaddrinfo(srvlist[srv].target,portstr,&hints,&res)!=0)
if(getaddrinfo(srvlist[srv].target,portstr,&hints,&res)==0)
hostfound=1;
else
continue;
for(ai=res;ai;ai=ai->ai_next)
@ -849,9 +851,15 @@ connect_server( const char *server, ushort port, unsigned int flags )
if(!connected)
{
#ifdef _WIN32
log_error("%s: host not found: ec=%d\n",server,(int)WSAGetLastError());
if(hostfound)
log_error("%s: Unable to connect: ec=%d\n",server,(int)WSAGetLastError());
else
log_error("%s: Host not found: ec=%d\n",server,(int)WSAGetLastError());
#else
log_error("%s: host not found\n",server);
if(hostfound)
log_error("%s: %s\n",server,strerror(errno));
else
log_error("%s: Host not found\n",server);
#endif
if(sock!=-1)
sock_close(sock);