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

* http.c (connect_server): Fix fd leak when connecting to a round-robin

server set that has some down servers.  Noted by Phil Pennock.
This commit is contained in:
David Shaw 2005-02-01 20:55:35 +00:00
parent 9af66d4634
commit f7a0254e63
2 changed files with 15 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2005-02-01 David Shaw <dshaw@jabberwocky.com>
* http.c (connect_server): Fix fd leak when connecting to a
round-robin server set that has some down servers. Noted by Phil
Pennock.
2005-01-20 Werner Koch <wk@g10code.com> 2005-01-20 Werner Koch <wk@g10code.com>
* simple-gettext.c (set_gettext_file): Use MO files depending on * simple-gettext.c (set_gettext_file): Use MO files depending on

View File

@ -859,6 +859,8 @@ connect_server( const char *server, ushort port, unsigned int flags,
connected=1; connected=1;
break; break;
} }
sock_close(sock);
} }
freeaddrinfo(res); freeaddrinfo(res);
@ -880,6 +882,8 @@ connect_server( const char *server, ushort port, unsigned int flags,
if((host=gethostbyname(srvlist[srv].target))==NULL) if((host=gethostbyname(srvlist[srv].target))==NULL)
continue; continue;
hostfound=1;
if((sock=socket(host->h_addrtype,SOCK_STREAM,0))==-1) if((sock=socket(host->h_addrtype,SOCK_STREAM,0))==-1)
{ {
log_error("error creating socket: %s\n",strerror(errno)); log_error("error creating socket: %s\n",strerror(errno));
@ -917,6 +921,8 @@ connect_server( const char *server, ushort port, unsigned int flags,
if(host->h_addr_list[i]) if(host->h_addr_list[i])
break; break;
sock_close(sock);
} }
#endif /* !HAVE_GETADDRINFO */ #endif /* !HAVE_GETADDRINFO */
@ -930,13 +936,15 @@ connect_server( const char *server, ushort port, unsigned int flags,
else else
log_error("%s: Host not found: ec=%d\n",server,(int)WSAGetLastError()); log_error("%s: Host not found: ec=%d\n",server,(int)WSAGetLastError());
#else #else
int err=errno;
if(hostfound) if(hostfound)
log_error("%s: %s\n",server,strerror(errno)); log_error("%s: %s\n",server,strerror(err));
else else
log_error("%s: Host not found\n",server); log_error("%s: Host not found\n",server);
#endif #endif
if(sock!=-1) if(sock!=-1)
sock_close(sock); sock_close(sock);
errno=err;
return -1; return -1;
} }