From 1fc3a57210b61cc73a91757f5d7ddc4050dc5f7f Mon Sep 17 00:00:00 2001 From: Kamen Mazdrashki Date: Thu, 19 Jun 2014 20:41:37 +0200 Subject: [PATCH] oc: Protect backend initialization to happen only once --- OpenChange/MAPIStoreSOGo.m | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/OpenChange/MAPIStoreSOGo.m b/OpenChange/MAPIStoreSOGo.m index 570c06d86..6975ab966 100644 --- a/OpenChange/MAPIStoreSOGo.m +++ b/OpenChange/MAPIStoreSOGo.m @@ -140,8 +140,14 @@ sogo_backend_init (void) Class MAPIApplicationK; NSUserDefaults *ud; SoProductRegistry *registry; + static BOOL moduleInitialized = NO; char *argv[] = { SAMBA_PREFIX "/sbin/samba", NULL }; + if (moduleInitialized) { + DEBUG(0, ("SOGo backend already initialized.\n")); + return MAPISTORE_SUCCESS; + } + GSRegisterCurrentThread (); pool = [NSAutoreleasePool new]; @@ -185,6 +191,7 @@ sogo_backend_init (void) [pool release]; DEBUG(0, ("[SOGo: %s:%d] backend init SUCCESS. Current thread: %p, pid: %d\n", __FUNCTION__, __LINE__, GSCurrentThread(), getpid())); + moduleInitialized = YES; return MAPISTORE_SUCCESS; }