-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
src/hostip.c: Move macOS-specific calls into global init call
curl#7121 introduced a macOS system call to `SCDynamicStoreCopyProxies`, which is invoked every time an IP address needs to be resolved. However, this system call is not thread-safe, and macOS will kill the process if the system call is run first in a fork. To make it possible for the parent process to call this once and prevent the crash, only invoke this system call in the global initialization routine. Closes curl#11252
- Loading branch information
Showing
5 changed files
with
108 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/*************************************************************************** | ||
* _ _ ____ _ | ||
* Project ___| | | | _ \| | | ||
* / __| | | | |_) | | | ||
* | (__| |_| | _ <| |___ | ||
* \___|\___/|_| \_\_____| | ||
* | ||
* Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. | ||
* | ||
* This software is licensed as described in the file COPYING, which | ||
* you should have received as part of this distribution. The terms | ||
* are also available at https://curl.se/docs/copyright.html. | ||
* | ||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell | ||
* copies of the Software, and permit persons to whom the Software is | ||
* furnished to do so, under the terms of the COPYING file. | ||
* | ||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
* KIND, either express or implied. | ||
* | ||
* SPDX-License-Identifier: curl | ||
* | ||
***************************************************************************/ | ||
|
||
#include "curl_setup.h" | ||
|
||
#if defined(__APPLE__) | ||
|
||
#if defined(TARGET_OS_OSX) && TARGET_OS_OSX | ||
|
||
#include <curl/curl.h> | ||
|
||
#if defined(ENABLE_IPV6) && defined(CURL_OSX_CALL_COPYPROXIES) | ||
#include <SystemConfiguration/SCDynamicStoreCopySpecific.h> | ||
#endif | ||
|
||
CURLcode Curl_macos_init(void) | ||
{ | ||
#if defined(ENABLE_IPV6) && defined(CURL_OSX_CALL_COPYPROXIES) | ||
{ | ||
/* | ||
* The automagic conversion from IPv4 literals to IPv6 literals only | ||
* works if the SCDynamicStoreCopyProxies system function gets called | ||
* first. As Curl currently doesn't support system-wide HTTP proxies, we | ||
* therefore don't use any value this function might return. | ||
* | ||
* This function is only available on a macOS and is not needed for | ||
* IPv4-only builds, hence the conditions above. | ||
*/ | ||
CFDictionaryRef dict = SCDynamicStoreCopyProxies(NULL); | ||
if(dict) | ||
CFRelease(dict); | ||
} | ||
#endif | ||
return CURLE_OK; | ||
} | ||
|
||
#endif /* TARGET_OS_OSX */ | ||
|
||
#endif /* __APPLE__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#ifndef HEADER_CURL_MACOS_H | ||
#define HEADER_CURL_MACOS_H | ||
/*************************************************************************** | ||
* _ _ ____ _ | ||
* Project ___| | | | _ \| | | ||
* / __| | | | |_) | | | ||
* | (__| |_| | _ <| |___ | ||
* \___|\___/|_| \_\_____| | ||
* | ||
* Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. | ||
* | ||
* This software is licensed as described in the file COPYING, which | ||
* you should have received as part of this distribution. The terms | ||
* are also available at https://curl.se/docs/copyright.html. | ||
* | ||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell | ||
* copies of the Software, and permit persons to whom the Software is | ||
* furnished to do so, under the terms of the COPYING file. | ||
* | ||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
* KIND, either express or implied. | ||
* | ||
* SPDX-License-Identifier: curl | ||
* | ||
***************************************************************************/ | ||
#include "curl_setup.h" | ||
|
||
#if defined(__APPLE__) && defined(TARGET_OS_OSX) && TARGET_OS_OSX | ||
|
||
CURLcode Curl_macos_init(void); | ||
|
||
#else | ||
|
||
#define Curl_macos_init() CURLE_OK | ||
|
||
#endif | ||
|
||
#endif /* HEADER_CURL_MACOS_H */ |