diff options
author | David Shaw <[email protected]> | 2002-09-24 21:06:20 +0000 |
---|---|---|
committer | David Shaw <[email protected]> | 2002-09-24 21:06:20 +0000 |
commit | c5faf2270a20455d3eb1f9ff88ce854083219337 (patch) | |
tree | 3c15834feabe50f7110872da2e77a2d0037eb385 | |
parent | * gpgkeys_ldap.c (ldap_err_to_gpg_err, ldap_to_gpg_err, send_key, get_key, (diff) | |
download | gnupg-c5faf2270a20455d3eb1f9ff88ce854083219337.tar.gz gnupg-c5faf2270a20455d3eb1f9ff88ce854083219337.zip |
* http.c (connect_server): Try all A records for names with multiple
addresses until one answers (not MINGW32).
-rw-r--r-- | util/ChangeLog | 5 | ||||
-rw-r--r-- | util/http.c | 21 |
2 files changed, 22 insertions, 4 deletions
diff --git a/util/ChangeLog b/util/ChangeLog index 1b87ec0bb..be623cf7e 100644 --- a/util/ChangeLog +++ b/util/ChangeLog @@ -1,3 +1,8 @@ +2002-09-24 David Shaw <[email protected]> + + * http.c (connect_server): Try all A records for names with + multiple addresses until one answers (not MINGW32). + 2002-09-16 Werner Koch <[email protected]> * w32reg.c (read_w32_registry_string): Fallback to HLM. diff --git a/util/http.c b/util/http.c index 23556b7bd..7f356bcbd 100644 --- a/util/http.c +++ b/util/http.c @@ -756,6 +756,7 @@ connect_server( const char *server, ushort port ) #else struct sockaddr_in addr; struct hostent *host; + int i=0; addr.sin_family = AF_INET; addr.sin_port = htons(port); @@ -763,16 +764,28 @@ connect_server( const char *server, ushort port ) if( !host ) return -1; - addr.sin_addr = *(struct in_addr*)host->h_addr; - sd = socket(AF_INET, SOCK_STREAM, 0); if( sd == -1 ) return -1; - if( connect( sd, (struct sockaddr *)&addr, sizeof addr) == -1 ) { + /* Try all A records until one responds. TODO: do this on the + MINGW32 side as well. */ + do + { + addr.sin_addr = *(struct in_addr*)host->h_addr_list[i]; + if(connect( sd, (struct sockaddr *)&addr, sizeof addr) == 0) + break; + + i++; + } + while(addr.sin_addr.s_addr!=0); + + if(addr.sin_addr.s_addr==0) + { sock_close(sd); return -1; - } + } + #endif return sd; } |