Skip to content

Commit

Permalink
fix(addressbook): close DB connection after DAV query
Browse files Browse the repository at this point in the history
  • Loading branch information
cgx committed Feb 1, 2022
1 parent 7c81e3a commit 348a79c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
3 changes: 2 additions & 1 deletion SoObjects/Contacts/SOGoContactSourceFolder.m
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -700,6 +700,7 @@ - (void) _appendComponentProperties: (NSArray *) properties
RELEASE(pool);
[response appendContentString: buffer];
RELEASE(buffer);
[source releaseConnection: connection];
// NSLog (@"/adding properties with url");

NSZoneFree (NULL, propertiesArray);
Expand Down
8 changes: 7 additions & 1 deletion SoObjects/SOGo/LDAPSource.m
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -497,6 +497,12 @@ - (NGLdapConnection *) _ldapConnection
return (NGLdapConnection *)[self connection];
}

- (void) releaseConnection: (id) connection
{
if ([(NGLdapConnection *)connection isBound])
[(NGLdapConnection *)connection unbind];
}

- (NSString *) domain
{
return _domain;
Expand Down
3 changes: 2 additions & 1 deletion SoObjects/SOGo/SOGoSource.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
Expand Down
17 changes: 13 additions & 4 deletions SoObjects/SOGo/SQLSource.m
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,17 @@ - (id) connection
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
Expand Down Expand Up @@ -678,18 +689,16 @@ - (NSDictionary *) _lookupContactEntry: (NSString *) theID
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;
}
Expand Down

0 comments on commit 348a79c

Please sign in to comment.