Skip to content

Commit 7eaefb6

Browse files
Apple Open Sourceopensource-apple
authored andcommitted
1 parent 7250ef2 commit 7eaefb6

File tree

12 files changed

+63
-27
lines changed

12 files changed

+63
-27
lines changed

AppServices.subproj/CFUserNotification.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <CoreFoundation/CFRunLoop.h>
3333
#include "CFInternal.h"
3434

35+
3536
#define __kCFLogUserNotification 20
3637
#define CFUserNotificationLog(alertHeader, alertMessage) CFLog(__kCFLogUserNotification, CFSTR("%@: %@"), alertHeader, alertMessage);
3738

Base.subproj/CFFileUtilities.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ __private_extern__ Boolean _CFReadBytesFromFile(CFAllocatorRef alloc, CFURLRef u
102102

103103
*bytes = NULL;
104104

105+
105106
#if defined(__WIN32__)
106107
fd = open(path, O_RDONLY|CF_OPENFLGS, 0666|_S_IREAD);
107108
#else

Base.subproj/CFInternal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
#include "auto_stubs.h"
5757
#include <libkern/OSAtomic.h>
5858

59+
5960
#if defined(__MACH__)
6061
#if defined(__ppc__)
6162
// This hack is in here because B&I kernel does not set up comm page with Tiger additions yet.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ include framework.make
7474
# Misc additional options
7575
#
7676

77-
CURRENT_PROJECT_VERSION = 368.26
77+
CURRENT_PROJECT_VERSION = 368.27
7878

7979
# common items all build styles should be defining
8080
CFLAGS += -DCF_BUILDING_CF=1

Parsing.subproj/CFPropertyList.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include <math.h>
4444
#include <ctype.h>
4545

46+
4647
__private_extern__ bool allowMissingSemi = false;
4748

4849
// Should move this somewhere else

PlugIn.subproj/CFBundle.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
#endif
7979
#endif
8080

81+
8182
// Public CFBundle Info plist keys
8283
CONST_STRING_DECL(kCFBundleInfoDictionaryVersionKey, "CFBundleInfoDictionaryVersion")
8384
CONST_STRING_DECL(kCFBundleExecutableKey, "CFBundleExecutable")
@@ -2315,6 +2316,7 @@ Boolean CFBundleLoadExecutable(CFBundleRef bundle) {
23152316
CFLog(__kCFLogBundle, CFSTR("Cannot recognize type of executable for %@"), bundle);
23162317
break;
23172318
}
2319+
if (result && bundle->_plugInData._isPlugIn) _CFBundlePlugInLoaded(bundle);
23182320

23192321
return result;
23202322
}
@@ -2685,11 +2687,13 @@ static void _CFBundleEnsureBundleExistsForImagePath(CFStringRef imagePath) {
26852687
// If an image path corresponds to a bundle, we see if there is already a bundle instance. If there is and it is NOT in the _dynamicBundles array, it is added to the staticBundles. Do not add the main bundle to the list here.
26862688
CFBundleRef bundle;
26872689
CFURLRef curURL = _CFBundleCopyFrameworkURLForExecutablePath(NULL, imagePath);
2690+
Boolean doFinalProcessing = false;
26882691

26892692
if (curURL != NULL) {
26902693
bundle = _CFBundleFindByURL(curURL, true);
26912694
if (bundle == NULL) {
2692-
bundle = _CFBundleCreate(NULL, curURL, true, true);
2695+
bundle = _CFBundleCreate(NULL, curURL, true, false);
2696+
doFinalProcessing = true;
26932697
}
26942698
if (bundle != NULL && !bundle->_isLoaded) {
26952699
// make sure that these bundles listed as loaded, and mark them frameworks (we probably can't see anything else here, and we cannot unload them)
@@ -2704,6 +2708,16 @@ static void _CFBundleEnsureBundleExistsForImagePath(CFStringRef imagePath) {
27042708
#endif /* BINARY_SUPPORT_DYLD */
27052709
bundle->_isLoaded = true;
27062710
}
2711+
// Perform delayed final processing steps.
2712+
// This must be done after _isLoaded has been set.
2713+
if (bundle && doFinalProcessing) {
2714+
_CFBundleCheckWorkarounds(bundle);
2715+
if (_CFBundleNeedsInitPlugIn(bundle)) {
2716+
__CFSpinUnlock(&CFBundleGlobalDataLock);
2717+
_CFBundleInitPlugIn(bundle);
2718+
__CFSpinLock(&CFBundleGlobalDataLock);
2719+
}
2720+
}
27072721
CFRelease(curURL);
27082722
}
27092723
}

PlugIn.subproj/CFBundle_Internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ extern void *_CFBundleDLLGetSymbolByName(CFBundleRef bundle, CFStringRef symbolN
138138

139139
extern Boolean _CFBundleNeedsInitPlugIn(CFBundleRef bundle);
140140
extern void _CFBundleInitPlugIn(CFBundleRef bundle);
141+
extern void _CFBundlePlugInLoaded(CFBundleRef bundle);
141142
extern void _CFBundleDeallocatePlugIn(CFBundleRef bundle);
142143

143144
extern void _CFPlugInWillUnload(CFPlugInRef plugIn);

PlugIn.subproj/CFPlugIn_PlugIn.c

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "CFBundle_Internal.h"
2929
#include "CFInternal.h"
3030

31+
3132
static void _registerFactory(const void *key, const void *val, void *context) {
3233
CFStringRef factoryIDStr = (CFStringRef)key;
3334
CFStringRef factoryFuncStr = (CFStringRef)val;
@@ -120,32 +121,44 @@ __private_extern__ void _CFBundleInitPlugIn(CFBundleRef bundle) {
120121
CFDictionaryApplyFunction(typeDict, _registerType, bundle);
121122
}
122123

123-
/* Now do dynamic registration if necessary */
124+
/* Now set key for dynamic registration if necessary */
124125
if (doDynamicReg) {
126+
CFDictionarySetValue((CFMutableDictionaryRef)infoDict, CFSTR("CFPlugInNeedsDynamicRegistration"), CFSTR("YES"));
127+
if (CFBundleIsExecutableLoaded(bundle)) _CFBundlePlugInLoaded(bundle);
128+
}
129+
}
130+
131+
__private_extern__ void _CFBundlePlugInLoaded(CFBundleRef bundle) {
132+
CFDictionaryRef infoDict = CFBundleGetInfoDictionary(bundle);
133+
CFStringRef tempStr;
134+
CFPlugInDynamicRegisterFunction func = NULL;
135+
136+
if (!__CFBundleGetPlugInData(bundle)->_isPlugIn || __CFBundleGetPlugInData(bundle)->_isDoingDynamicRegistration || !infoDict || !CFBundleIsExecutableLoaded(bundle)) return;
137+
138+
tempStr = CFDictionaryGetValue(infoDict, CFSTR("CFPlugInNeedsDynamicRegistration"));
139+
if (tempStr != NULL && CFGetTypeID(tempStr) == CFStringGetTypeID() && CFStringCompare(tempStr, CFSTR("YES"), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
140+
CFDictionaryRemoveValue((CFMutableDictionaryRef)infoDict, CFSTR("CFPlugInNeedsDynamicRegistration"));
125141
tempStr = CFDictionaryGetValue(infoDict, kCFPlugInDynamicRegisterFunctionKey);
126142
if (tempStr == NULL || CFGetTypeID(tempStr) != CFStringGetTypeID() || CFStringGetLength(tempStr) <= 0) {
127143
tempStr = CFSTR("CFPlugInDynamicRegister");
128144
}
129145
__CFBundleGetPlugInData(bundle)->_loadOnDemand = false;
146+
__CFBundleGetPlugInData(bundle)->_isDoingDynamicRegistration = true;
130147

131-
if (CFBundleLoadExecutable(bundle)) {
132-
CFPlugInDynamicRegisterFunction func = NULL;
133-
134-
__CFBundleGetPlugInData(bundle)->_isDoingDynamicRegistration = true;
135-
136-
/* Find the symbol and call it. */
137-
func = (CFPlugInDynamicRegisterFunction)CFBundleGetFunctionPointerForName(bundle, tempStr);
138-
if (func) {
139-
func(bundle);
140-
// MF:!!! Unload function is never called. Need to deal with this!
141-
}
148+
/* Find the symbol and call it. */
149+
func = (CFPlugInDynamicRegisterFunction)CFBundleGetFunctionPointerForName(bundle, tempStr);
150+
if (func) {
151+
func(bundle);
152+
// MF:!!! Unload function is never called. Need to deal with this!
153+
}
142154

143-
__CFBundleGetPlugInData(bundle)->_isDoingDynamicRegistration = false;
144-
if (__CFBundleGetPlugInData(bundle)->_loadOnDemand && (__CFBundleGetPlugInData(bundle)->_instanceCount == 0)) {
145-
/* Unload now if we can/should. */
146-
CFBundleUnloadExecutable(bundle);
147-
}
155+
__CFBundleGetPlugInData(bundle)->_isDoingDynamicRegistration = false;
156+
if (__CFBundleGetPlugInData(bundle)->_loadOnDemand && (__CFBundleGetPlugInData(bundle)->_instanceCount == 0)) {
157+
/* Unload now if we can/should. */
158+
CFBundleUnloadExecutable(bundle);
148159
}
160+
} else {
161+
CFDictionaryRemoveValue((CFMutableDictionaryRef)infoDict, CFSTR("CFPlugInNeedsDynamicRegistration"));
149162
}
150163
}
151164

@@ -169,7 +182,8 @@ UInt32 CFPlugInGetTypeID(void) {
169182
}
170183

171184
CFPlugInRef CFPlugInCreate(CFAllocatorRef allocator, CFURLRef plugInURL) {
172-
return (CFPlugInRef)CFBundleCreate(allocator, plugInURL);
185+
CFBundleRef bundle = CFBundleCreate(allocator, plugInURL);
186+
return (CFPlugInRef)bundle;
173187
}
174188

175189
CFBundleRef CFPlugInGetBundle(CFPlugInRef plugIn) {

Preferences.subproj/CFApplicationPreferences.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <CoreFoundation/CFUniChar.h>
3131
#include <CoreFoundation/CFNumber.h>
3232

33+
3334
static Boolean _CFApplicationPreferencesSynchronizeNoLock(_CFApplicationPreferences *self);
3435
void _CFPreferencesDomainSetMultiple(CFPreferencesDomainRef domain, CFDictionaryRef dict);
3536
static void updateDictRep(_CFApplicationPreferences *self);

RunLoop.subproj/CFMessagePort.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include <math.h>
4242
#include <mach/mach_time.h>
4343

44+
4445
#define __kCFMessagePortMaxNameLengthMax 255
4546

4647
#if defined(BOOTSTRAP_MAX_NAME_LEN)
@@ -647,7 +648,7 @@ SInt32 CFMessagePortSendRequest(CFMessagePortRef remote, SInt32 msgid, CFDataRef
647648
Boolean didRegister = false;
648649
kern_return_t ret;
649650

650-
//#warning CF: This should be an assert
651+
//#warning CF: This should be an assert
651652
// if (!__CFMessagePortIsRemote(remote)) return -999;
652653
if (!__CFMessagePortIsValid(remote)) return kCFMessagePortIsInvalid;
653654
__CFMessagePortLock(remote);

0 commit comments

Comments
 (0)