Monotone-Parent: ff27cb5c0c118c485e7cf9d8e62d4428edafdb32

Monotone-Revision: 8373ee4a182606382fcb3aea7864b142db4aaa95

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2008-12-12T18:55:12
Monotone-Branch: ca.inverse.sogo
maint-2.0.2
Wolfgang Sourdeau 2008-12-12 18:55:12 +00:00
parent 5f04a776f0
commit 72efdaa9a1
5 changed files with 231 additions and 51 deletions

View File

@ -23,6 +23,7 @@
#import <Foundation/NSCalendarDate.h> #import <Foundation/NSCalendarDate.h>
#import <Foundation/NSDictionary.h> #import <Foundation/NSDictionary.h>
#import <Foundation/NSEnumerator.h> #import <Foundation/NSEnumerator.h>
#import <Foundation/NSLock.h>
#import <Foundation/NSTimer.h> #import <Foundation/NSTimer.h>
#import <Foundation/NSUserDefaults.h> #import <Foundation/NSUserDefaults.h>
@ -44,6 +45,10 @@
(eg missing release due to an exception) (eg missing release due to an exception)
*/ */
#if defined(THREADSAFE)
static NSLock *lock;
#endif
@interface GCSChannelHandle : NSObject @interface GCSChannelHandle : NSObject
{ {
@public @public
@ -82,6 +87,10 @@ static NSTimeInterval ChannelCollectionTimer = 5 * 60;
[[ud objectForKey: @"GCSChannelCollectionTimer"] intValue]; [[ud objectForKey: @"GCSChannelCollectionTimer"] intValue];
if (ChannelCollectionTimer < 1) if (ChannelCollectionTimer < 1)
ChannelCollectionTimer = 5*60; ChannelCollectionTimer = 5*60;
#if defined(THREADSAFE)
lock = [NSLock new];
#endif
} }
+ (NSString *) adaptorNameForURLScheme: (NSString *) _scheme + (NSString *) adaptorNameForURLScheme: (NSString *) _scheme
@ -94,8 +103,14 @@ static NSTimeInterval ChannelCollectionTimer = 5 * 60;
{ {
static GCSChannelManager *cm = nil; static GCSChannelManager *cm = nil;
#if defined(THREADSAFE)
[lock lock];
#endif
if (!cm) if (!cm)
cm = [self new]; cm = [self new];
#if defined(THREADSAFE)
[lock unlock];
#endif
return cm; return cm;
} }
@ -184,6 +199,9 @@ static NSTimeInterval ChannelCollectionTimer = 5 * 60;
{ {
if ((key = [self databaseKeyForURL: _url])) if ((key = [self databaseKeyForURL: _url]))
{ {
#if defined(THREADSAFE)
[lock lock];
#endif
adaptor = [urlToAdaptor objectForKey: key]; adaptor = [urlToAdaptor objectForKey: key];
if (adaptor) if (adaptor)
[self debugWithFormat: @"using cached adaptor: %@", adaptor]; [self debugWithFormat: @"using cached adaptor: %@", adaptor];
@ -215,6 +233,9 @@ static NSTimeInterval ChannelCollectionTimer = 5 * 60;
[urlToAdaptor setObject: adaptor forKey: key]; [urlToAdaptor setObject: adaptor forKey: key];
} }
#if defined(THREADSAFE)
[lock unlock];
#endif
} }
} }
@ -295,6 +316,9 @@ static NSTimeInterval ChannelCollectionTimer = 5 * 60;
/* look for cached handles */ /* look for cached handles */
#if defined(THREADSAFE)
[lock lock];
#endif
handle = [self findAvailChannelHandleForURL: _url]; handle = [self findAvailChannelHandleForURL: _url];
if (handle) if (handle)
{ {
@ -339,6 +363,9 @@ static NSTimeInterval ChannelCollectionTimer = 5 * 60;
channel, [_url absoluteString]]; channel, [_url absoluteString]];
} }
} }
#if defined(THREADSAFE)
[lock unlock];
#endif
return channel; return channel;
} }
@ -347,6 +374,9 @@ static NSTimeInterval ChannelCollectionTimer = 5 * 60;
{ {
GCSChannelHandle *handle; GCSChannelHandle *handle;
#if defined(THREADSAFE)
[lock lock];
#endif
handle = [self findBusyChannelHandleForChannel: _channel]; handle = [self findBusyChannelHandleForChannel: _channel];
if (handle) if (handle)
{ {
@ -380,6 +410,9 @@ static NSTimeInterval ChannelCollectionTimer = 5 * 60;
[_channel release]; [_channel release];
} }
#if defined(THREADSAFE)
[lock unlock];
#endif
} }
/* checking for tables */ /* checking for tables */
@ -428,6 +461,9 @@ static NSTimeInterval ChannelCollectionTimer = 5 * 60;
unsigned i, count; unsigned i, count;
GCSChannelHandle *handle; GCSChannelHandle *handle;
#if defined(THREADSAFE)
[lock lock];
#endif
count = [availableChannels count]; count = [availableChannels count];
if (count) if (count)
{ {
@ -462,6 +498,9 @@ static NSTimeInterval ChannelCollectionTimer = 5 * 60;
[handlesToRemove release]; [handlesToRemove release];
} }
#if defined(THREADSAFE)
[lock unlock];
#endif
} }
/* debugging */ /* debugging */

View File

@ -19,7 +19,23 @@
02111-1307, USA. 02111-1307, USA.
*/ */
#import <Foundation/NSArray.h>
#import <Foundation/NSCharacterSet.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSException.h>
#import <Foundation/NSLock.h>
#import <Foundation/NSProcessInfo.h> #import <Foundation/NSProcessInfo.h>
#import <Foundation/NSSet.h>
#import <Foundation/NSString.h>
#import <Foundation/NSUserDefaults.h>
#import <NGExtensions/NSNull+misc.h>
#import <NGExtensions/NSObject+Logs.h>
#import <GDLAccess/EOAdaptorChannel.h>
#import <GDLAccess/EOAdaptorContext.h>
#import <NGExtensions/NGResourceLocator.h>
#import <unistd.h>
#import "GCSFolderManager.h" #import "GCSFolderManager.h"
#import "GCSChannelManager.h" #import "GCSChannelManager.h"
@ -27,11 +43,6 @@
#import "GCSFolder.h" #import "GCSFolder.h"
#import "NSURL+GCS.h" #import "NSURL+GCS.h"
#import "EOAdaptorChannel+GCS.h" #import "EOAdaptorChannel+GCS.h"
#import "common.h"
#import <GDLAccess/EOAdaptorChannel.h>
#import <GDLAccess/EOAdaptorContext.h>
#import <NGExtensions/NGResourceLocator.h>
#import <unistd.h>
/* /*
Required database schema: Required database schema:
@ -64,6 +75,10 @@ static NSString *GCSGenericFolderTypeName = @"Container";
static const char *GCSPathColumnPattern = "c_path%i"; static const char *GCSPathColumnPattern = "c_path%i";
static NSCharacterSet *asciiAlphaNumericCS = nil; static NSCharacterSet *asciiAlphaNumericCS = nil;
#if defined(THREADSAFE)
static NSLock *lock;
#endif
+ (void) initialize + (void) initialize
{ {
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
@ -76,6 +91,9 @@ static NSCharacterSet *asciiAlphaNumericCS = nil;
debugOn = [ud boolForKey: @"GCSFolderManagerDebugEnabled"]; debugOn = [ud boolForKey: @"GCSFolderManagerDebugEnabled"];
debugSQLGen = [ud boolForKey: @"GCSFolderManagerSQLDebugEnabled"]; debugSQLGen = [ud boolForKey: @"GCSFolderManagerSQLDebugEnabled"];
emptyArray = [[NSArray alloc] init]; emptyArray = [[NSArray alloc] init];
#if defined(THREADSAFE)
lock = [NSLock new];
#endif
if (!asciiAlphaNumericCS) if (!asciiAlphaNumericCS)
{ {
asciiAlphaNumericCS asciiAlphaNumericCS
@ -90,26 +108,34 @@ static NSCharacterSet *asciiAlphaNumericCS = nil;
+ (id)defaultFolderManager { + (id)defaultFolderManager {
NSString *s; NSString *s;
NSURL *url; NSURL *url;
if (fm) return fm;
#if defined(THREADSAFE)
s = [[NSUserDefaults standardUserDefaults] stringForKey:@"OCSFolderInfoURL"]; [lock lock];
if ([s length] == 0) { #endif
NSLog(@"ERROR(%s): default 'OCSFolderInfoURL' is not configured.", if (!fm)
__PRETTY_FUNCTION__); {
return nil; s = [[NSUserDefaults standardUserDefaults] stringForKey:@"OCSFolderInfoURL"];
} if ([s length] == 0) {
if ((url = [NSURL URLWithString:s]) == nil) { NSLog(@"ERROR(%s): default 'OCSFolderInfoURL' is not configured.",
NSLog(@"ERROR(%s): default 'OCSFolderInfoURL' is not a valid URL: '%@'", __PRETTY_FUNCTION__);
__PRETTY_FUNCTION__, s); return nil;
return nil; }
} if ((url = [NSURL URLWithString:s]) == nil) {
if ((fm = [[self alloc] initWithFolderInfoLocation:url]) == nil) { NSLog(@"ERROR(%s): default 'OCSFolderInfoURL' is not a valid URL: '%@'",
NSLog(@"ERROR(%s): could not create folder manager with URL: '%@'", __PRETTY_FUNCTION__, s);
__PRETTY_FUNCTION__, [url absoluteString]); return nil;
return nil; }
} if ((fm = [[self alloc] initWithFolderInfoLocation:url]) == nil) {
NSLog(@"ERROR(%s): could not create folder manager with URL: '%@'",
NSLog(@"Note: setup default manager at: %@", url); __PRETTY_FUNCTION__, [url absoluteString]);
return nil;
}
NSLog(@"Note: setup default manager at: %@", url);
}
#if defined(THREADSAFE)
[lock unlock];
#endif
return fm; return fm;
} }
@ -199,6 +225,7 @@ static NSCharacterSet *asciiAlphaNumericCS = nil;
ch = [[self channelManager] acquireOpenChannelForURL: ch = [[self channelManager] acquireOpenChannelForURL:
[self folderInfoLocation]]; [self folderInfoLocation]];
return ch; return ch;
} }
- (void)releaseChannel:(EOAdaptorChannel *)_channel { - (void)releaseChannel:(EOAdaptorChannel *)_channel {

View File

@ -23,6 +23,7 @@
#import <Foundation/NSArray.h> #import <Foundation/NSArray.h>
#import <Foundation/NSDictionary.h> #import <Foundation/NSDictionary.h>
#import <Foundation/NSEnumerator.h> #import <Foundation/NSEnumerator.h>
#import <Foundation/NSLock.h>
#import <Foundation/NSString.h> #import <Foundation/NSString.h>
#import <Foundation/NSTimer.h> #import <Foundation/NSTimer.h>
#import <Foundation/NSUserDefaults.h> #import <Foundation/NSUserDefaults.h>
@ -38,6 +39,10 @@ static NSString *LDAPContactInfoAttribute = nil;
static BOOL defaultMailDomainIsConfigured = NO; static BOOL defaultMailDomainIsConfigured = NO;
static BOOL forceImapLoginWithEmail = NO; static BOOL forceImapLoginWithEmail = NO;
#if defined(THREADSAFE)
static NSLock *lock;
#endif
@implementation LDAPUserManager @implementation LDAPUserManager
+ (void) initialize + (void) initialize
@ -64,6 +69,9 @@ static BOOL forceImapLoginWithEmail = NO;
} }
if (!forceImapLoginWithEmail) if (!forceImapLoginWithEmail)
forceImapLoginWithEmail = [ud boolForKey: @"SOGoForceIMAPLoginWithEmail"]; forceImapLoginWithEmail = [ud boolForKey: @"SOGoForceIMAPLoginWithEmail"];
#if defined(THREADSAFE)
lock = [NSLock new];
#endif
} }
+ (BOOL) defaultMailDomainIsConfigured + (BOOL) defaultMailDomainIsConfigured
@ -75,8 +83,14 @@ static BOOL forceImapLoginWithEmail = NO;
{ {
static id sharedUserManager = nil; static id sharedUserManager = nil;
#if defined(THREADSAFE)
[lock lock];
#endif
if (!sharedUserManager) if (!sharedUserManager)
sharedUserManager = [self new]; sharedUserManager = [self new];
#if defined(THREADSAFE)
[lock unlock];
#endif
return sharedUserManager; return sharedUserManager;
} }
@ -149,16 +163,18 @@ static BOOL forceImapLoginWithEmail = NO;
cleanupInterval = 0.0; cleanupInterval = 0.0;
if (cleanupInterval > 0.0) if (cleanupInterval > 0.0)
{ {
cleanupTimer = [NSTimer scheduledTimerWithTimeInterval: cleanupInterval cleanupTimer
target: self = [NSTimer scheduledTimerWithTimeInterval: cleanupInterval
selector: @selector (_cleanupSources) target: self
userInfo: nil selector: @selector (_cleanupSources)
repeats: YES]; userInfo: nil
repeats: YES];
[self logWithFormat: @"cleanup interval set every %f seconds", [self logWithFormat: @"cleanup interval set every %f seconds",
cleanupInterval]; cleanupInterval];
} }
else else
[self logWithFormat: @"no cleanup interval set: memory usage will grow"]; [self
logWithFormat: @"no cleanup interval set: memory usage will grow"];
[self _prepareLDAPSourcesWithDefaults: ud]; [self _prepareLDAPSourcesWithDefaults: ud];
} }
@ -300,6 +316,10 @@ static BOOL forceImapLoginWithEmail = NO;
NSMutableDictionary *currentUser; NSMutableDictionary *currentUser;
NSString *dictPassword; NSString *dictPassword;
#if defined(THREADSAFE)
[lock lock];
#endif
currentUser = [users objectForKey: login]; currentUser = [users objectForKey: login];
dictPassword = [currentUser objectForKey: @"password"]; dictPassword = [currentUser objectForKey: @"password"];
if (currentUser && dictPassword) if (currentUser && dictPassword)
@ -323,6 +343,10 @@ static BOOL forceImapLoginWithEmail = NO;
[currentUser setObject: cleanupDate forKey: @"cleanupDate"]; [currentUser setObject: cleanupDate forKey: @"cleanupDate"];
} }
#if defined(THREADSAFE)
[lock unlock];
#endif
return checkOK; return checkOK;
} }
@ -402,12 +426,18 @@ static BOOL forceImapLoginWithEmail = NO;
NSString *key; NSString *key;
NSEnumerator *emails; NSEnumerator *emails;
#if defined(THREADSAFE)
[lock lock];
#endif
key = [newUser objectForKey: @"c_uid"]; key = [newUser objectForKey: @"c_uid"];
if (key) if (key)
[users setObject: newUser forKey: key]; [users setObject: newUser forKey: key];
emails = [[newUser objectForKey: @"emails"] objectEnumerator]; emails = [[newUser objectForKey: @"emails"] objectEnumerator];
while ((key = [emails nextObject])) while ((key = [emails nextObject]))
[users setObject: newUser forKey: key]; [users setObject: newUser forKey: key];
#if defined(THREADSAFE)
[lock unlock];
#endif
} }
- (NSDictionary *) contactInfosForUserWithUIDorEmail: (NSString *) uid - (NSDictionary *) contactInfosForUserWithUIDorEmail: (NSString *) uid
@ -420,6 +450,9 @@ static BOOL forceImapLoginWithEmail = NO;
{ {
contactInfos = [NSMutableDictionary dictionary]; contactInfos = [NSMutableDictionary dictionary];
currentUser = [users objectForKey: uid]; currentUser = [users objectForKey: uid];
#if defined(THREADSAFE)
[lock lock];
#endif
if (!([currentUser objectForKey: @"emails"] if (!([currentUser objectForKey: @"emails"]
&& [currentUser objectForKey: @"cn"])) && [currentUser objectForKey: @"cn"]))
{ {
@ -446,6 +479,9 @@ static BOOL forceImapLoginWithEmail = NO;
cleanupDate = [[NSDate date] addTimeInterval: cleanupInterval]; cleanupDate = [[NSDate date] addTimeInterval: cleanupInterval];
[currentUser setObject: cleanupDate forKey: @"cleanupDate"]; [currentUser setObject: cleanupDate forKey: @"cleanupDate"];
} }
#if defined(THREADSAFE)
[lock unlock];
#endif
} }
else else
currentUser = nil; currentUser = nil;
@ -453,18 +489,6 @@ static BOOL forceImapLoginWithEmail = NO;
return currentUser; return currentUser;
} }
- (void) _fillContactsMailRecords: (NSEnumerator *) contacts
{
NSMutableDictionary *currentContact;
currentContact = [contacts nextObject];
while (currentContact)
{
[self _fillContactMailRecords: currentContact];
currentContact = [contacts nextObject];
}
}
- (NSArray *) _compactAndCompleteContacts: (NSEnumerator *) contacts - (NSArray *) _compactAndCompleteContacts: (NSEnumerator *) contacts
{ {
NSMutableDictionary *compactContacts, *returnContact; NSMutableDictionary *compactContacts, *returnContact;
@ -517,10 +541,11 @@ static BOOL forceImapLoginWithEmail = NO;
[returnContact setObject: infoAttribute [returnContact setObject: infoAttribute
forKey: LDAPContactInfoAttribute]; forKey: LDAPContactInfoAttribute];
} }
[self _fillContactMailRecords: returnContact];
} }
} }
newContacts = [compactContacts allValues]; newContacts = [compactContacts allValues];
[self _fillContactsMailRecords: [newContacts objectEnumerator]];
return newContacts; return newContacts;
} }
@ -565,6 +590,10 @@ static BOOL forceImapLoginWithEmail = NO;
NSDate *now; NSDate *now;
unsigned int count; unsigned int count;
#if defined(THREADSAFE)
[lock lock];
#endif
now = [NSDate date]; now = [NSDate date];
count = 0; count = 0;
@ -583,6 +612,10 @@ static BOOL forceImapLoginWithEmail = NO;
if (count) if (count)
[self logWithFormat: @"cleaned %d users records from cache", count]; [self logWithFormat: @"cleaned %d users records from cache", count];
#if defined(THREADSAFE)
[lock unlock];
#endif
} }
@end @end

View File

@ -25,6 +25,7 @@
#import <Foundation/NSDictionary.h> #import <Foundation/NSDictionary.h>
#import <Foundation/NSDistributedNotificationCenter.h> #import <Foundation/NSDistributedNotificationCenter.h>
#import <Foundation/NSEnumerator.h> #import <Foundation/NSEnumerator.h>
#import <Foundation/NSLock.h>
#import <Foundation/NSString.h> #import <Foundation/NSString.h>
#import <Foundation/NSTimer.h> #import <Foundation/NSTimer.h>
#import <Foundation/NSUserDefaults.h> #import <Foundation/NSUserDefaults.h>
@ -51,8 +52,19 @@ static NSMutableDictionary *s_userSettings = nil;
static SOGoCache *sharedCache = nil; static SOGoCache *sharedCache = nil;
#if defined(THREADSAFE)
static NSLock *lock;
#endif
@implementation SOGoCache @implementation SOGoCache
#if defined(THREADSAFE)
+ (void) initialize
{
lock = [NSLock new];
}
#endif
+ (NSTimeInterval) cleanupInterval + (NSTimeInterval) cleanupInterval
{ {
return cleanupInterval; return cleanupInterval;
@ -60,16 +72,28 @@ static SOGoCache *sharedCache = nil;
+ (SOGoCache *) sharedCache + (SOGoCache *) sharedCache
{ {
#if defined(THREADSAFE)
[lock lock];
#endif
if (!sharedCache) if (!sharedCache)
sharedCache = [self new]; sharedCache = [self new];
#if defined(THREADSAFE)
[lock unlock];
#endif
return sharedCache; return sharedCache;
} }
+ (void) killCache + (void) killCache
{ {
#if defined(THREADSAFE)
[lock lock];
#endif
[cache removeAllObjects]; [cache removeAllObjects];
[users removeAllObjects]; [users removeAllObjects];
#if defined(THREADSAFE)
[lock unlock];
#endif
} }
- (id) init - (id) init
@ -134,7 +158,7 @@ static SOGoCache *sharedCache = nil;
} }
- (NSString *) _pathFromObject: (SOGoObject *) container - (NSString *) _pathFromObject: (SOGoObject *) container
withName: (NSString *) name withName: (NSString *) name
{ {
NSString *fullPath, *nameInContainer; NSString *fullPath, *nameInContainer;
NSMutableArray *names; NSMutableArray *names;
@ -169,13 +193,19 @@ static SOGoCache *sharedCache = nil;
inContainer: [container container]]; inContainer: [container container]];
fullPath = [self _pathFromObject: container fullPath = [self _pathFromObject: container
withName: name]; withName: name];
#if defined(THREADSAFE)
[lock lock];
#endif
if (![cache objectForKey: fullPath]) if (![cache objectForKey: fullPath])
{ {
// NSLog (@"registering '%@'", fullPath); // NSLog (@"registering '%@'", fullPath);
[cache setObject: object forKey: fullPath]; [cache setObject: object forKey: fullPath];
} }
// else #if defined(THREADSAFE)
// NSLog (@"'%@' already registered", fullPath); [lock unlock];
#endif
// else
// NSLog (@"'%@' already registered", fullPath);
} }
} }
@ -188,14 +218,20 @@ static SOGoCache *sharedCache = nil;
withName: name]; withName: name];
return [cache objectForKey: fullPath]; return [cache objectForKey: fullPath];
// if (object) // if (object)
// NSLog (@"found cached object '%@'", fullPath); // NSLog (@"found cached object '%@'", fullPath);
} }
- (void) registerUser: (SOGoUser *) user - (void) registerUser: (SOGoUser *) user
{ {
#if defined(THREADSAFE)
[lock lock];
#endif
[users setObject: user [users setObject: user
forKey: [user login]]; forKey: [user login]];
#if defined(THREADSAFE)
[lock unlock];
#endif
} }
- (id) userNamed: (NSString *) name - (id) userNamed: (NSString *) name
@ -214,11 +250,17 @@ static SOGoCache *sharedCache = nil;
{ {
NSDate *cleanupDate; NSDate *cleanupDate;
#if defined(THREADSAFE)
[lock lock];
#endif
cleanupDate = [[NSDate date] addTimeInterval: [SOGoCache cleanupInterval]]; cleanupDate = [[NSDate date] addTimeInterval: [SOGoCache cleanupInterval]];
[s_userDefaults setObject: [NSDictionary dictionaryWithObjectsAndKeys: [s_userDefaults setObject: [NSDictionary dictionaryWithObjectsAndKeys:
theDefaults, @"dictionary", theDefaults, @"dictionary",
cleanupDate, @"cleanupDate", nil] cleanupDate, @"cleanupDate", nil]
forKey: login]; forKey: login];
#if defined(THREADSAFE)
[lock unlock];
#endif
} }
+ (NSDictionary *) cachedUserSettings + (NSDictionary *) cachedUserSettings
@ -231,11 +273,17 @@ static SOGoCache *sharedCache = nil;
{ {
NSDate *cleanupDate; NSDate *cleanupDate;
#if defined(THREADSAFE)
[lock lock];
#endif
cleanupDate = [[NSDate date] addTimeInterval: [SOGoCache cleanupInterval]]; cleanupDate = [[NSDate date] addTimeInterval: [SOGoCache cleanupInterval]];
[s_userSettings setObject: [NSDictionary dictionaryWithObjectsAndKeys: [s_userSettings setObject: [NSDictionary dictionaryWithObjectsAndKeys:
theSettings, @"dictionary", theSettings, @"dictionary",
cleanupDate, @"cleanupDate", nil] cleanupDate, @"cleanupDate", nil]
forKey: login]; forKey: login];
#if defined(THREADSAFE)
[lock unlock];
#endif
} }
- (void) _userDefaultsHaveChanged: (NSNotification *) theNotification - (void) _userDefaultsHaveChanged: (NSNotification *) theNotification
@ -245,6 +293,9 @@ static SOGoCache *sharedCache = nil;
uid = [[theNotification userInfo] objectForKey: @"uid"]; uid = [[theNotification userInfo] objectForKey: @"uid"];
#if defined(THREADSAFE)
[lock lock];
#endif
if ((user = [users objectForKey: uid])) if ((user = [users objectForKey: uid]))
{ {
[[user userDefaults] setValues: [[theNotification userInfo] objectForKey: @"values"]]; [[user userDefaults] setValues: [[theNotification userInfo] objectForKey: @"values"]];
@ -254,6 +305,9 @@ static SOGoCache *sharedCache = nil;
{ {
[s_userDefaults removeObjectForKey: uid]; [s_userDefaults removeObjectForKey: uid];
} }
#if defined(THREADSAFE)
[lock unlock];
#endif
} }
- (void) _userSettingsHaveChanged: (NSNotification *) theNotification - (void) _userSettingsHaveChanged: (NSNotification *) theNotification
@ -283,6 +337,10 @@ static SOGoCache *sharedCache = nil;
unsigned int count; unsigned int count;
#if defined(THREADSAFE)
[lock lock];
#endif
now = [NSDate date]; now = [NSDate date];
// We cleanup the user defaults // We cleanup the user defaults
@ -317,7 +375,12 @@ static SOGoCache *sharedCache = nil;
} }
if (count) if (count)
[self logWithFormat: @"cleaned %d users records from user settings cache", count]; [self logWithFormat: @"cleaned %d users records from user settings cache",
count];
#if defined(THREADSAFE)
[lock unlock];
#endif
} }
@end @end

18
configure vendored
View File

@ -18,6 +18,7 @@ ARG_GSMAKE=`gnustep-config --variable=GNUSTEP_MAKEFILES 2>/dev/null`
ARG_CFGMAKE="$PWD/config.make" ARG_CFGMAKE="$PWD/config.make"
ARG_WITH_DEBUG=1 ARG_WITH_DEBUG=1
ARG_WITH_STRIP=0 ARG_WITH_STRIP=0
ARG_WITH_THREADS=0
ARG_WITH_LDAP_CONFIG=0 ARG_WITH_LDAP_CONFIG=0
GNUSTEP_INSTALLATION_DOMAIN="LOCAL" GNUSTEP_INSTALLATION_DOMAIN="LOCAL"
@ -58,6 +59,7 @@ Installation directories:
--configmake=PATH path to the config file being created --configmake=PATH path to the config file being created
--enable-debug turn on debugging and compile time warnings --enable-debug turn on debugging and compile time warnings
--enable-strip turn on stripping of debug symbols --enable-strip turn on stripping of debug symbols
--enable-thread-safety turn on thread-safety
--enable-ldap-config enable LDAP based configuration of SOGo --enable-ldap-config enable LDAP based configuration of SOGo
@ -83,6 +85,11 @@ printParas() {
else else
echo " strip: no"; echo " strip: no";
fi fi
if test $ARG_WITH_THREADS = 1; then
echo " thread-safe: yes";
else
echo " thread-safe: no";
fi
if test $ARG_WITH_LDAP_CONFIG = 1; then if test $ARG_WITH_LDAP_CONFIG = 1; then
echo " ldap-based configuration: yes"; echo " ldap-based configuration: yes";
else else
@ -261,6 +268,11 @@ genConfigMake() {
fi fi
cfgwrite "" cfgwrite ""
if test $ARG_WITH_THREADS = 1; then
cfgwrite "# configured to produce thread-safe code";
cfgwrite "ADDITIONAL_CPPFLAGS += -DTHREADSAFE=1"
fi
cfgwrite "# enforce shared libraries"; cfgwrite "# enforce shared libraries";
cfgwrite "shared:=yes" cfgwrite "shared:=yes"
cfgwrite "" cfgwrite ""
@ -393,6 +405,12 @@ processOption() {
"x--disable-strip") "x--disable-strip")
ARG_WITH_STRIP=0 ARG_WITH_STRIP=0
;; ;;
"x--enable-thread-safety")
ARG_WITH_THREADS=1
;;
"x--disable-thread-safety")
ARG_WITH_THREADS=0
;;
"x--enable-ldap-config") "x--enable-ldap-config")
ARG_WITH_LDAP_CONFIG=1 ARG_WITH_LDAP_CONFIG=1