Module: check_mk
Branch: master
Commit: bb87bbc6a98c48f17be49fcda5feaee80004ac01
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=bb87bbc6a98c48…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Jul 11 09:26:50 2016 +0200
3669 FIX LDAP: Fixed very long running LDAP sync when using group based sync plugins
---
.werks/3669 | 10 ++++++++++
ChangeLog | 1 +
web/htdocs/index.py | 14 +++++++++-----
web/htdocs/userdb.py | 28 ++++++++++++++++++++++++++--
4 files changed, 46 insertions(+), 7 deletions(-)
diff --git a/.werks/3669 b/.werks/3669
new file mode 100644
index 0000000..45dca6b
--- /dev/null
+++ b/.werks/3669
@@ -0,0 +1,10 @@
+Title: LDAP: Fixed very long running LDAP sync when using group based sync plugins
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.4.0i1
+Date: 1468221930
+
+
diff --git a/ChangeLog b/ChangeLog
index a1d2e69..ad0a5c1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -388,6 +388,7 @@
* 3659 FIX: Fixed GUI exceptions for users having special characters in ther user
names
* 3662 FIX: Fixed creation/editing of dashboards (regression since 1.2.8p5)
* 3668 FIX: Fixed slow loading of GUI pages when using a localized GUI
+ * 3669 FIX: LDAP: Fixed very long running LDAP sync when using group based sync
plugins
WATO:
* 3244 WATO BI Module: swap order of aggregation function and child node
selection...
diff --git a/web/htdocs/index.py b/web/htdocs/index.py
index ab7342b..a99db40 100644
--- a/web/htdocs/index.py
+++ b/web/htdocs/index.py
@@ -30,6 +30,7 @@ import i18n
import sites
import livestatus
import modules
+import userdb
import defaults, config, login
from lib import *
from html_mod_python import html_mod_python, FinalizeRequest
@@ -173,9 +174,7 @@ def handler(req, fields = None, is_profiling = False):
except (apache.SERVER_RETURN,
(apache.SERVER_RETURN, apache.HTTP_UNAUTHORIZED),
(apache.SERVER_RETURN, apache.HTTP_MOVED_TEMPORARILY)):
- release_all_locks()
- sites.disconnect()
- html.finalize(is_error=True)
+ finalize_request(is_error=True)
raise
except Exception, e:
@@ -191,10 +190,15 @@ def handler(req, fields = None, is_profiling = False):
modules.get_handler("gui_crash")()
response_code = apache.OK
+ finalize_request()
+ return response_code
+
+
+def finalize_request(is_error=False):
release_all_locks()
+ userdb.finalize()
sites.disconnect()
- html.finalize()
- return response_code
+ html.finalize(is_error=is_error)
# Ajax-Functions want no HTML output in case of an error but
diff --git a/web/htdocs/userdb.py b/web/htdocs/userdb.py
index 2644f34..f81b872 100644
--- a/web/htdocs/userdb.py
+++ b/web/htdocs/userdb.py
@@ -35,7 +35,11 @@ loaded_with_language = False
# Custom user attributes
user_attributes = {}
builtin_user_attribute_names = []
+
+# Connection configuration
connection_dict = {}
+# Connection object dictionary
+g_connections = {}
# Load all userdb plugins
def load_plugins(force):
@@ -56,6 +60,10 @@ def load_plugins(force):
for connection in config.user_connections:
connection_dict[connection['id']] = connection
+ # Cleanup eventual still open connections
+ if g_connections:
+ g_connections.clear()
+
global loaded_with_language
if loaded_with_language == current_language and not force:
return
@@ -79,6 +87,12 @@ def load_plugins(force):
loaded_with_language = current_language
+# Cleans up at the end of a request: Cleanup eventual open connections
+def finalize():
+ if g_connections:
+ g_connections.clear()
+
+
# Returns a list of two part tuples where the first element is the unique
# connection id and the second element the connector specification dict
def get_connections(only_enabled=False):
@@ -133,9 +147,19 @@ def cleanup_connection_id(connection_id):
return connection_id
-# Returns the connector dictionary of the given id
+# Returns the connection object of the requested connection id. This function
+# maintains a cache that for a single connection_id only one object per request
+# is created.
def get_connection(connection_id):
- return dict(get_connections()).get(connection_id)
+ if connection_id in g_connections:
+ return g_connections[connection_id]
+
+ connection = dict(get_connections()).get(connection_id)
+
+ if connection:
+ g_connections[connection_id] = connection
+
+ return connection
# Returns a list of connection specific locked attributes