MacOS Legacy: simplify, don't forget change monitoring

pull/775/head
Brad House 7 months ago
parent ea6a75c1a7
commit ef7bffe6fa
  1. 21
      src/lib/ares_event_configchg.c
  2. 14
      src/lib/ares_sysconfig_mac.c

@ -334,6 +334,12 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg,
const char *(*pdns_configuration_notify_key)(void) = NULL;
const char *notify_key = NULL;
int flags;
size_t i;
const char *searchlibs[] = {
"/usr/lib/libSystem.dylib",
"/System/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration",
NULL
};
*configchg = ares_malloc_zero(sizeof(**configchg));
if (*configchg == NULL) {
@ -341,13 +347,22 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg,
}
/* Load symbol as it isn't normally public */
handle = dlopen("/usr/lib/libSystem.dylib", RTLD_LAZY | RTLD_NOLOAD);
for (i=0; searchlibs[i] != NULL; i++) {
handle = dlopen(searchlibs[i], RTLD_LAZY);
if (handle == NULL) {
status = ARES_ESERVFAIL;
goto done;
/* Fail, loop! */
continue;
}
pdns_configuration_notify_key = dlsym(handle, "dns_configuration_notify_key");
if (pdns_configuration_notify_key != NULL) {
break;
}
/* Fail, loop! */
dlclose(handle);
handle = NULL;
}
if (pdns_configuration_notify_key == NULL) {
status = ARES_ESERVFAIL;

@ -85,9 +85,7 @@ static ares_status_t dnsinfo_init(dnsinfo_t **dnsinfo_out)
size_t i;
const char *searchlibs[] = {
"/usr/lib/libSystem.dylib",
"SystemConfiguration.framework/SystemConfiguration",
"/System/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration",
"/System/Library/Frameworks/SystemConfiguration.framework/Versions/Current/SystemConfiguration",
NULL
};
@ -114,21 +112,9 @@ static ares_status_t dnsinfo_init(dnsinfo_t **dnsinfo_out)
dnsinfo->dns_configuration_copy =
dlsym(dnsinfo->handle, "dns_configuration_copy");
if (dnsinfo->dns_configuration_copy == NULL) {
/* Might be needed for PPC ABI */
dnsinfo->dns_configuration_copy =
dlsym(dnsinfo->handle, "_dns_configuration_copy");
}
dnsinfo->dns_configuration_free =
dlsym(dnsinfo->handle, "dns_configuration_free");
if (dnsinfo->dns_configuration_free == NULL) {
/* Might be needed for PPC ABI */
dnsinfo->dns_configuration_free =
dlsym(dnsinfo->handle, "_dns_configuration_free");
}
if (dnsinfo->dns_configuration_copy != NULL &&
dnsinfo->dns_configuration_free != NULL) {
break;

Loading…
Cancel
Save