From 348a79c79513936445cc8e8073723ad2f262c510 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Tue, 1 Feb 2022 10:14:37 -0500 Subject: [PATCH] fix(addressbook): close DB connection after DAV query --- SoObjects/Contacts/SOGoContactSourceFolder.m | 3 ++- SoObjects/SOGo/LDAPSource.m | 8 +++++++- SoObjects/SOGo/SOGoSource.h | 3 ++- SoObjects/SOGo/SQLSource.m | 17 +++++++++++++---- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/SoObjects/Contacts/SOGoContactSourceFolder.m b/SoObjects/Contacts/SOGoContactSourceFolder.m index 64a89ce3d..a264c93f8 100644 --- a/SoObjects/Contacts/SOGoContactSourceFolder.m +++ b/SoObjects/Contacts/SOGoContactSourceFolder.m @@ -1,6 +1,6 @@ /* SOGoContactSourceFolder.m - this file is part of SOGo * - * Copyright (C) 2006-2021 Inverse inc. + * Copyright (C) 2006-2022 Inverse inc. * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -700,6 +700,7 @@ RELEASE(pool); [response appendContentString: buffer]; RELEASE(buffer); + [source releaseConnection: connection]; // NSLog (@"/adding properties with url"); NSZoneFree (NULL, propertiesArray); diff --git a/SoObjects/SOGo/LDAPSource.m b/SoObjects/SOGo/LDAPSource.m index 24c31e35b..fdc57d1de 100644 --- a/SoObjects/SOGo/LDAPSource.m +++ b/SoObjects/SOGo/LDAPSource.m @@ -1,6 +1,6 @@ /* LDAPSource.m - this file is part of SOGo * - * Copyright (C) 2007-2021 Inverse inc. + * Copyright (C) 2007-2022 Inverse inc. * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -497,6 +497,12 @@ groupObjectClasses: (NSArray *) newGroupObjectClasses return (NGLdapConnection *)[self connection]; } +- (void) releaseConnection: (id) connection +{ + if ([(NGLdapConnection *)connection isBound]) + [(NGLdapConnection *)connection unbind]; +} + - (NSString *) domain { return _domain; diff --git a/SoObjects/SOGo/SOGoSource.h b/SoObjects/SOGo/SOGoSource.h index 55aa027fa..d6ac6d785 100644 --- a/SoObjects/SOGo/SOGoSource.h +++ b/SoObjects/SOGo/SOGoSource.h @@ -1,6 +1,6 @@ /* SOGoSource.h - this file is part of SOGo * - * Copyright (C) 2009-2021 Inverse inc. + * Copyright (C) 2009-2022 Inverse inc. * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -40,6 +40,7 @@ - (NSArray *) searchFields; - (id) connection; +- (void) releaseConnection: (id) connection; /* requires a "." to obtain the full list of contacts */ - (void) setListRequiresDot: (BOOL) aBool; diff --git a/SoObjects/SOGo/SQLSource.m b/SoObjects/SOGo/SQLSource.m index 5f2e63538..7221afd89 100644 --- a/SoObjects/SOGo/SQLSource.m +++ b/SoObjects/SOGo/SQLSource.m @@ -440,6 +440,17 @@ return channel; } +- (void) releaseConnection: (id) connection +{ + GCSChannelManager *cm; + + if (connection) + { + cm = [GCSChannelManager defaultChannelManager]; + [cm releaseChannel: connection]; + } +} + - (NSDictionary *) _lookupContactEntry: (NSString *) theID considerEmail: (BOOL) b inDomain: (NSString *) domain @@ -678,18 +689,16 @@ inDomain: (NSString *) domain { EOAdaptorChannel *channel; - GCSChannelManager *cm; NSDictionary *response; - cm = [GCSChannelManager defaultChannelManager]; channel = (EOAdaptorChannel *)[self connection]; response = [self _lookupContactEntry: theID considerEmail: b inDomain: domain usingConnection: channel]; - if (channel) - [cm releaseChannel: channel]; + + [self releaseConnection: channel]; return response; }