From cecf157dca4e0748d23b871c250484092c41598b Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Fri, 10 Jul 2020 10:22:48 -0400 Subject: [PATCH] fix(core): avoid pooling channels with tools (fixes #4684) --- SOPE/GDLContentStore/GCSFolder.h | 3 +++ SOPE/GDLContentStore/GCSFolder.m | 9 ++++++++- Tools/SOGoToolBackup.m | 6 +++--- Tools/SOGoToolCheckupUser.m | 4 ++-- Tools/SOGoToolCleanupUser.m | 4 ++-- Tools/SOGoToolExpireUserSessions.m | 4 ++-- Tools/SOGoToolManageACL.m | 2 +- Tools/SOGoToolRemove.m | 6 +++--- Tools/SOGoToolRemoveDoubles.m | 4 ++-- Tools/SOGoToolRenameUser.m | 16 ++++++++-------- Tools/SOGoToolRestore.m | 6 +++--- Tools/SOGoToolTruncateCalendar.m | 4 ++-- Tools/sogo-tool.m | 6 +++--- 13 files changed, 42 insertions(+), 32 deletions(-) diff --git a/SOPE/GDLContentStore/GCSFolder.h b/SOPE/GDLContentStore/GCSFolder.h index 934cf3fc7..b3e9936ed 100644 --- a/SOPE/GDLContentStore/GCSFolder.h +++ b/SOPE/GDLContentStore/GCSFolder.h @@ -108,6 +108,9 @@ - (EOAdaptorChannel *) acquireQuickChannel; - (EOAdaptorChannel *) acquireAclChannel; - (void) releaseChannel: (EOAdaptorChannel *) _channel; +- (void) releaseChannel: (EOAdaptorChannel *) _channel + immediately: (BOOL) _immediately; + - (BOOL) canConnectStore; - (BOOL) canConnectQuick; diff --git a/SOPE/GDLContentStore/GCSFolder.m b/SOPE/GDLContentStore/GCSFolder.m index 9f0da454b..3e2f738e3 100644 --- a/SOPE/GDLContentStore/GCSFolder.m +++ b/SOPE/GDLContentStore/GCSFolder.m @@ -248,9 +248,16 @@ static GCSStringFormatter *stringFormatter = nil; return [[self _channelManager] acquireOpenChannelForURL:[self aclLocation]]; } + - (void)releaseChannel:(EOAdaptorChannel *)_channel { + [self releaseChannel: _channel immediately: NO]; +} + +- (void) releaseChannel: (EOAdaptorChannel *) _channel + immediately: (BOOL) _immediately +{ if (debugOn) [self debugWithFormat:@"releasing channel: %@", _channel]; - [[self _channelManager] releaseChannel:_channel]; + [[self _channelManager] releaseChannel:_channel immediately: _immediately]; } - (BOOL)canConnectStore { diff --git a/Tools/SOGoToolBackup.m b/Tools/SOGoToolBackup.m index c906773d5..c1489f115 100644 --- a/Tools/SOGoToolBackup.m +++ b/Tools/SOGoToolBackup.m @@ -1,6 +1,6 @@ /* SOGoToolBackup.m - this file is part of SOGo * - * Copyright (C) 2009-2016 Inverse inc. + * Copyright (C) 2009-2020 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 @@ -168,7 +168,7 @@ if (user) [allSqlUsers addObject: user]; } - [cm releaseChannel: fc]; + [cm releaseChannel: fc immediately: YES]; users = allSqlUsers; max = [users count]; @@ -270,7 +270,7 @@ row = [fc fetchAttributes: attrs withZone: NULL]; displayName = [row objectForKey: @"c_foldername"]; [fc cancelFetch]; - [cm releaseChannel: fc]; + [cm releaseChannel: fc immediately: YES]; } if (!displayName) diff --git a/Tools/SOGoToolCheckupUser.m b/Tools/SOGoToolCheckupUser.m index cd68708ec..611b671c9 100644 --- a/Tools/SOGoToolCheckupUser.m +++ b/Tools/SOGoToolCheckupUser.m @@ -1,6 +1,6 @@ /* SOGoToolCheckup.m - this file is part of SOGo * - * Copyright (C) 2017 Inverse inc. + * Copyright (C) 2017-2020 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 @@ -128,7 +128,7 @@ if (user) [allSqlUsers addObject: user]; } - [cm releaseChannel: fc]; + [cm releaseChannel: fc immediately: YES]; users = allSqlUsers; max = [users count]; diff --git a/Tools/SOGoToolCleanupUser.m b/Tools/SOGoToolCleanupUser.m index 65d57a48e..6ff8b828d 100644 --- a/Tools/SOGoToolCleanupUser.m +++ b/Tools/SOGoToolCleanupUser.m @@ -1,6 +1,6 @@ /* SOGoToolCleanup.m - this file is part of SOGo * - * Copyright (C) 2016 Inverse inc. + * Copyright (C) 2016-2020 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 @@ -122,7 +122,7 @@ if (user) [allSqlUsers addObject: user]; } - [cm releaseChannel: fc]; + [cm releaseChannel: fc immediately: YES]; users = allSqlUsers; max = [users count]; diff --git a/Tools/SOGoToolExpireUserSessions.m b/Tools/SOGoToolExpireUserSessions.m index 721c44691..3be6d1d75 100644 --- a/Tools/SOGoToolExpireUserSessions.m +++ b/Tools/SOGoToolExpireUserSessions.m @@ -1,6 +1,6 @@ /* SOGoToolExpireUserSessions.m - this file is part of SOGo * - * Copyright (C) 2012-2017 Inverse inc. + * Copyright (C) 2012-2020 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 @@ -134,7 +134,7 @@ NSLog(@"No session to remove"); } - [cm releaseChannel: channel]; + [cm releaseChannel: channel immediately: YES]; return rc; } diff --git a/Tools/SOGoToolManageACL.m b/Tools/SOGoToolManageACL.m index 8794dfff8..331f543bf 100644 --- a/Tools/SOGoToolManageACL.m +++ b/Tools/SOGoToolManageACL.m @@ -206,7 +206,7 @@ typedef enum if (u) [allSQLUsers addObject: u]; } - [cm releaseChannel: fc]; + [cm releaseChannel: fc immediately: YES]; } // We add our system users diff --git a/Tools/SOGoToolRemove.m b/Tools/SOGoToolRemove.m index 43720267a..6ee4cbc72 100644 --- a/Tools/SOGoToolRemove.m +++ b/Tools/SOGoToolRemove.m @@ -1,6 +1,6 @@ /* SOGoToolRemove.m - this file is part of SOGo * - * Copyright (C) 2010-2017 Inverse inc. + * Copyright (C) 2010-2020 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 @@ -105,7 +105,7 @@ static NSURL *tableURL = nil; while ((row = [fc fetchAttributes: attrs withZone: NULL])) [paths addObject: [row objectForKey: @"c_path"]]; } - [cm releaseChannel: fc]; + [cm releaseChannel: fc immediately: YES]; } return paths; @@ -150,7 +150,7 @@ static NSURL *tableURL = nil; NSLog (@"Unable to delete the preference record for '%@'", userId); else if (verbose) NSLog (@"Removed preference record for '%@'", userId); - [cm releaseChannel: fc]; + [cm releaseChannel: fc immediately: YES]; } } diff --git a/Tools/SOGoToolRemoveDoubles.m b/Tools/SOGoToolRemoveDoubles.m index 5dcb28023..7a188a55c 100644 --- a/Tools/SOGoToolRemoveDoubles.m +++ b/Tools/SOGoToolRemoveDoubles.m @@ -1,6 +1,6 @@ /* SOGoToolRemoveDoubles.m - this file is part of SOGo * - * Copyright (C) 2009-2017 Inverse inc. + * Copyright (C) 2009-2020 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 @@ -207,7 +207,7 @@ usingChannel: channel]; [context commitTransaction]; - [folder releaseChannel: channel]; + [folder releaseChannel: channel immediately: YES]; } - (NSArray *) namesOfRecords: (NSArray *) records diff --git a/Tools/SOGoToolRenameUser.m b/Tools/SOGoToolRenameUser.m index 7d054794a..fb73d46c3 100644 --- a/Tools/SOGoToolRenameUser.m +++ b/Tools/SOGoToolRenameUser.m @@ -1,6 +1,6 @@ /* SOGoToolRenameUser.m - this file is part of SOGo * - * Copyright (C) 2011-2017 Inverse inc + * Copyright (C) 2011-2020 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 @@ -147,7 +147,7 @@ else rc = [ac commitTransaction]; - [cm releaseChannel: fc]; + [cm releaseChannel: fc immediately: YES]; return rc; } @@ -200,7 +200,7 @@ else rc = [ac commitTransaction]; - [cm releaseChannel: fc]; + [cm releaseChannel: fc immediately: YES]; return rc; } @@ -245,7 +245,7 @@ while ((row = [fc fetchAttributes: attrs withZone: NULL])) [subscribers addObject: [row objectForKey: @"c_uid"]]; [fc cancelFetch]; - [cm releaseChannel: fc]; + [cm releaseChannel: fc immediately: YES]; return subscribers; } @@ -446,7 +446,7 @@ sql = [NSString stringWithFormat: @"UPDATE %@ SET c_object = '%@'", [location gcsTableName], newObjectPath]; [ac evaluateExpressionX: sql]; - [cm releaseChannel: ac]; + [cm releaseChannel: ac immediately: YES]; } [pool release]; @@ -480,7 +480,7 @@ fromSQLUser: sqlFromUserID toSQLUser: sqlToUserID]; [fc cancelFetch]; - [cm releaseChannel: fc]; + [cm releaseChannel: fc immediately: YES]; } - (void) _updateForeignACLsForLocation: (NSString *) locationString @@ -505,7 +505,7 @@ [location gcsTableName], sqlToUserID, sqlFromUserID]; [tc evaluateExpressionX: sql]; - [cm releaseChannel: tc]; + [cm releaseChannel: tc immediately: YES]; [pool release]; } @@ -537,7 +537,7 @@ fromSQLUser: sqlFromUserID toSQLUser: sqlToUserID]; [fc cancelFetch]; - [cm releaseChannel: fc]; + [cm releaseChannel: fc immediately: YES]; } - (BOOL) proceed diff --git a/Tools/SOGoToolRestore.m b/Tools/SOGoToolRestore.m index 90cad1ea3..f976ca30c 100644 --- a/Tools/SOGoToolRestore.m +++ b/Tools/SOGoToolRestore.m @@ -1,6 +1,6 @@ /* SOGoToolRestore.m - this file is part of SOGo * - * Copyright (C) 2009-2019 Inverse inc. + * Copyright (C) 2009-2020 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 @@ -312,7 +312,7 @@ withString: @"''"], [gcsFolder path]]; [fc evaluateExpressionX: sql]; - [cm releaseChannel: fc]; + [cm releaseChannel: fc immediately: YES]; } } else @@ -365,7 +365,7 @@ } [[channel adaptorContext] commitTransaction]; - [gcsFolder releaseChannel: channel]; + [gcsFolder releaseChannel: channel immediately: YES]; rc = YES; } diff --git a/Tools/SOGoToolTruncateCalendar.m b/Tools/SOGoToolTruncateCalendar.m index 3b3e0bced..65714799b 100644 --- a/Tools/SOGoToolTruncateCalendar.m +++ b/Tools/SOGoToolTruncateCalendar.m @@ -1,6 +1,6 @@ /* SOGoToolTruncateCalendar.m - this file is part of SOGo * - * Copyright (C) 2009-2016 Inverse inc. + * Copyright (C) 2009-2020 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 @@ -108,7 +108,7 @@ } [context commitTransaction]; - [folder releaseChannel: channel]; + [folder releaseChannel: channel immediately: YES]; } - (BOOL) truncateEntriesFromFolder: (GCSFolder *) folder diff --git a/Tools/sogo-tool.m b/Tools/sogo-tool.m index 59d157ac4..b4314af10 100644 --- a/Tools/sogo-tool.m +++ b/Tools/sogo-tool.m @@ -83,9 +83,9 @@ - (void) parseArguments: (NSArray *) arguments { - BOOL error; - int count, max; NSString *argument; + int count, max; + BOOL error; error = NO; @@ -104,7 +104,7 @@ { error = YES; helpMode = YES; - NSLog (@"Invalid command line parameter: '%@'", argument); + NSLog(@"Invalid command line parameter: '%@'", argument); } else {