Skip to content

Commit

Permalink
Comment known CFNetworkExecuteProxyAutoConfigurationURL leak.
Browse files Browse the repository at this point in the history
  • Loading branch information
nmoinvaz committed Jan 18, 2024
1 parent bd082bf commit 2061ab4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion resolver_mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,21 @@ bool proxy_resolver_mac_get_proxies_for_url(void *ctx, const char *url) {

CFStreamClientContext context = {0, proxy_resolver, NULL, NULL, NULL};

// There is a known issue mentioned in Chromium source, that the run loop instance
// returned by CFNetworkExecuteProxyAutoConfigurationURL leaks.

// Additionally it is discussed on these forums:
// http://www.openradar.appspot.com/20974299
// https://forums.developer.apple.com/forums/thread/724883
// https://stackoverflow.com/questions/53290871

CFRunLoopSourceRef run_loop = CFNetworkExecuteProxyAutoConfigurationURL(
url_ref, target_url_ref, proxy_resolver_mac_auto_config_result_callback, &context);
if (!run_loop) {
proxy_resolver->error = ELOOP;
LOG_ERROR("Failed to execute pac url (%" PRId64 ")\n", proxy_resolver->error);
goto mac_done;
}

CFRunLoopAddSource(CFRunLoopGetCurrent(), run_loop, PROXY_RESOLVER_RUN_LOOP);
CFRunLoopRunInMode(PROXY_RESOLVER_RUN_LOOP, PROXY_RESOLVER_TIMEOUT_SEC, false);
CFRunLoopRemoveSource(CFRunLoopGetCurrent(), run_loop, PROXY_RESOLVER_RUN_LOOP);
Expand Down

0 comments on commit 2061ab4

Please sign in to comment.