[106085] trunk/dports/security/certsync
landonf at macports.org
landonf at macports.org
Tue May 14 09:26:09 PDT 2013
Revision: 106085
https://trac.macports.org/changeset/106085
Author: landonf at macports.org
Date: 2013-05-14 09:26:09 -0700 (Tue, 14 May 2013)
Log Message:
-----------
Be more aggressive with retaining/releasing autoprelease pools as to keep memory usage at an absolute minimum.
Modified Paths:
--------------
trunk/dports/security/certsync/Portfile
trunk/dports/security/certsync/files/certsync.m
Modified: trunk/dports/security/certsync/Portfile
===================================================================
--- trunk/dports/security/certsync/Portfile 2013-05-14 16:12:03 UTC (rev 106084)
+++ trunk/dports/security/certsync/Portfile 2013-05-14 16:26:09 UTC (rev 106085)
@@ -2,7 +2,7 @@
PortSystem 1.0
name certsync
-version 1.0.2
+version 1.0.3
categories security
conflicts curl-ca-bundle
maintainers landonf openmaintainer
Modified: trunk/dports/security/certsync/files/certsync.m
===================================================================
--- trunk/dports/security/certsync/files/certsync.m 2013-05-14 16:12:03 UTC (rev 106084)
+++ trunk/dports/security/certsync/files/certsync.m 2013-05-14 16:26:09 UTC (rev 106085)
@@ -128,9 +128,10 @@
} else if (err != errSecSuccess) {
/* Lookup failed */
if (outError != NULL)
- *outError = [NSError errorWithDomain: NSOSStatusErrorDomain code: err userInfo:nil];
+ *outError = [[NSError errorWithDomain: NSOSStatusErrorDomain code: err userInfo:nil] retain];
[pool release];
+ [*outError autorelease];
return nil;
}
@@ -290,11 +291,15 @@
static void certsync_keychain_cb (ConstFSEventStreamRef streamRef, void *clientCallBackInfo, size_t numEvents, void *eventPaths, const FSEventStreamEventFlags eventFlags[], const FSEventStreamEventId eventIds[])
{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
MPCertSyncConfig *config = (MPCertSyncConfig *) clientCallBackInfo;
int ret;
if ((ret = exportCertificates(config->userAnchors, config->outputFile)) != EXIT_SUCCESS)
exit(ret);
+
+ [pool release];
}
int main (int argc, char * const argv[]) {
@@ -333,46 +338,55 @@
argv += optind;
/* Perform single-shot export */
- if (!runServer)
+ if (NO && !runServer)
return exportCertificates(userAnchors, outputFile);
/* Formulate the list of directories to observe; We use FSEvents rather than SecKeychainAddCallback(), as during testing the keychain
* API never actually fired a callback for the target keychains. */
- NSSearchPathDomainMask searchPathDomains = NSLocalDomainMask|NSSystemDomainMask;
- if (userAnchors)
- searchPathDomains |= NSUserDomainMask;
+ FSEventStreamRef eventStream;
+ {
+ NSAutoreleasePool *streamPool = [[NSAutoreleasePool alloc] init];
- NSArray *libraryDirectories = NSSearchPathForDirectoriesInDomains(NSAllLibrariesDirectory, searchPathDomains, YES);
- NSMutableArray *keychainDirectories = [NSMutableArray arrayWithCapacity: [libraryDirectories count]];
- for (NSString *dir in libraryDirectories) {
- [keychainDirectories addObject: [dir stringByAppendingPathComponent: @"Keychains"]];
- [keychainDirectories addObject: [dir stringByAppendingPathComponent: @"Security/Trust Settings"]];
- }
+ NSSearchPathDomainMask searchPathDomains = NSLocalDomainMask|NSSystemDomainMask;
+ if (userAnchors)
+ searchPathDomains |= NSUserDomainMask;
- /* Configure the listener */
- FSEventStreamRef eventStream;
- MPCertSyncConfig *config = [[[MPCertSyncConfig alloc] init] autorelease];
- config->userAnchors = userAnchors;
- config->outputFile = [outputFile retain];
+ NSArray *libraryDirectories = NSSearchPathForDirectoriesInDomains(NSAllLibrariesDirectory, searchPathDomains, YES);
+ NSMutableArray *keychainDirectories = [NSMutableArray arrayWithCapacity: [libraryDirectories count]];
+ for (NSString *dir in libraryDirectories) {
+ [keychainDirectories addObject: [dir stringByAppendingPathComponent: @"Keychains"]];
+ [keychainDirectories addObject: [dir stringByAppendingPathComponent: @"Security/Trust Settings"]];
+ }
- FSEventStreamContext ctx = {
- .version = 0,
- .info = config,
- .retain = CFRetain,
- .release = CFRelease,
- .copyDescription = CFCopyDescription
- };
- eventStream = FSEventStreamCreate(NULL, certsync_keychain_cb, &ctx, (CFArrayRef)keychainDirectories, kFSEventStreamEventIdSinceNow, 0.0, kFSEventStreamCreateFlagUseCFTypes);
- FSEventStreamScheduleWithRunLoop(eventStream, CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
- FSEventStreamStart(eventStream);
+ /* Configure the listener */
+ MPCertSyncConfig *config = [[[MPCertSyncConfig alloc] init] autorelease];
+ config->userAnchors = userAnchors;
+ config->outputFile = [outputFile retain];
+ FSEventStreamContext ctx = {
+ .version = 0,
+ .info = config,
+ .retain = CFRetain,
+ .release = CFRelease,
+ .copyDescription = CFCopyDescription
+ };
+ eventStream = FSEventStreamCreate(NULL, certsync_keychain_cb, &ctx, (CFArrayRef)keychainDirectories, kFSEventStreamEventIdSinceNow, 0.0, kFSEventStreamCreateFlagUseCFTypes);
+ FSEventStreamScheduleWithRunLoop(eventStream, CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
+ FSEventStreamStart(eventStream);
+
+ [streamPool release];
+ }
+
/* Perform an initial one-shot export, and then run forever */
- int ret;
- if ((ret = exportCertificates(userAnchors, outputFile)) != EXIT_SUCCESS)
- return EXIT_FAILURE;
-
+ {
+ NSAutoreleasePool *shotPool = [[NSAutoreleasePool alloc] init];
+ int ret;
+ if ((ret = exportCertificates(userAnchors, outputFile)) != EXIT_SUCCESS)
+ return EXIT_FAILURE;
+ [shotPool release];
+ }
+
CFRunLoopRun();
-
FSEventStreamRelease(eventStream);
[pool release];
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20130514/5b321b49/attachment.html>
More information about the macports-changes
mailing list