ares_init_options: don't lose init failure

If (say) init_by_options() fails, the subsequent call to 
init_by_defaults() was overwriting the return code with
success.  Still call init_by_defaults() regardless, but track
its return value separately
pull/31/head
David Drysdale 9 years ago
parent 52c9bc57bd
commit 46bb820be3
  1. 8
      ares_init.c

@ -111,6 +111,7 @@ int ares_init_options(ares_channel *channelptr, struct ares_options *options,
ares_channel channel;
int i;
int status = ARES_SUCCESS;
int status2;
struct timeval now;
#ifdef CURLDEBUG
@ -209,10 +210,13 @@ int ares_init_options(ares_channel *channelptr, struct ares_options *options,
* No matter what failed or succeeded, seed defaults to provide
* useful behavior for things that we missed.
*/
status = init_by_defaults(channel);
if (status != ARES_SUCCESS)
status2 = init_by_defaults(channel);
if (status2 != ARES_SUCCESS) {
DEBUGF(fprintf(stderr, "Error: init_by_defaults failed: %s\n",
ares_strerror(status)));
if (status == ARES_SUCCESS)
status = status2;
}
/* Generate random key */

Loading…
Cancel
Save