[libgda] Honor the connection debug slowdown for direct LDAP calls



commit d664390df8e9a8910fadc318bc8cca9c30fdb0e5
Author: Vivien Malerba <malerba gnome-db org>
Date:   Wed Dec 3 21:57:35 2014 +0100

    Honor the connection debug slowdown for direct LDAP calls

 providers/ldap/gda-ldap-util.c           |   23 +++++++++++++++++++++++
 providers/ldap/gda-ldap-util.h           |    5 +++++
 providers/ldap/gdaprov-data-model-ldap.c |    1 +
 3 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/providers/ldap/gda-ldap-util.c b/providers/ldap/gda-ldap-util.c
index b4f09bb..704a9ff 100644
--- a/providers/ldap/gda-ldap-util.c
+++ b/providers/ldap/gda-ldap-util.c
@@ -406,6 +406,7 @@ worker_gda_ldap_get_attr_info (WorkerLdapAttrInfoData *data, GError **error)
        if (! gda_ldap_ensure_bound (data->cnc, NULL))
                return NULL;
 
+       gda_ldap_execution_slowdown (data->cnc);
        res = ldap_search_ext_s (data->cdata->handle, "", LDAP_SCOPE_BASE,
                                 "(objectclass=*)",
                                 subschemasubentry, 0,
@@ -438,6 +439,7 @@ worker_gda_ldap_get_attr_info (WorkerLdapAttrInfoData *data, GError **error)
        }
 
        /* look for attributeTypes */
+       gda_ldap_execution_slowdown (data->cnc);
        res = ldap_search_ext_s (data->cdata->handle, subschema, LDAP_SCOPE_BASE,
                                 "(objectclass=*)",
                                 schema_attrs, 0,
@@ -604,6 +606,7 @@ worker_gdaprov_ldap_get_class_info (WorkerLdapClassInfoData *data, GError **erro
        if (! gda_ldap_ensure_bound (data->cnc, NULL))
                return NULL;
 
+       gda_ldap_execution_slowdown (data->cnc);
        res = ldap_search_ext_s (data->cdata->handle, "", LDAP_SCOPE_BASE,
                                 "(objectclass=*)",
                                 subschemasubentry, 0,
@@ -636,6 +639,7 @@ worker_gdaprov_ldap_get_class_info (WorkerLdapClassInfoData *data, GError **erro
        }
 
        /* look for attributeTypes */
+       gda_ldap_execution_slowdown (data->cnc);
        res = ldap_search_ext_s (data->cdata->handle, subschema, LDAP_SCOPE_BASE,
                                 "(objectclass=*)",
                                 schema_attrs, 0,
@@ -1309,6 +1313,8 @@ worker_gdaprov_ldap_describe_entry (WorkerLdapDescrEntryData *data, GError **err
        if (! gda_ldap_ensure_bound (data->cnc, error))
                return NULL;
 
+       gda_ldap_execution_slowdown (data->cnc);
+
        int res;
        LDAPMessage *msg = NULL;
        const gchar *real_dn;
@@ -1825,3 +1831,20 @@ gdaprov_ldap_get_attributes_list (GdaLdapConnection *cnc, GdaLdapAttribute *obje
 
        return retlist;
 }
+
+/*
+ * gda_ldap_execution_slowdown:
+ *
+ * This function honors the GdaConnection:execution-slowdown property when using the LDAP interface
+ * directly
+ */
+void
+gda_ldap_execution_slowdown (GdaLdapConnection *cnc)
+{
+       guint delay;
+       g_object_get (cnc, "execution-slowdown", &delay, NULL);
+       if (delay > 0) {
+               g_print ("Delaying LDAP query execution for %u ms\n", delay);
+                g_usleep (delay);
+       }
+}
diff --git a/providers/ldap/gda-ldap-util.h b/providers/ldap/gda-ldap-util.h
index e3b32d8..244e431 100644
--- a/providers/ldap/gda-ldap-util.h
+++ b/providers/ldap/gda-ldap-util.h
@@ -58,4 +58,9 @@ gboolean       gda_ldap_parse_dn (const char *attr, gchar **out_userdn);
 
 gboolean       gdaprov_ldap_is_dn (const gchar *dn);
 
+/*
+ * Debug purposes
+ */
+void           gda_ldap_execution_slowdown (GdaLdapConnection *cnc);
+
 #endif
diff --git a/providers/ldap/gdaprov-data-model-ldap.c b/providers/ldap/gdaprov-data-model-ldap.c
index 90adbc5..bb37fb0 100644
--- a/providers/ldap/gdaprov-data-model-ldap.c
+++ b/providers/ldap/gdaprov-data-model-ldap.c
@@ -1040,6 +1040,7 @@ worker_execute_ldap_search (WorkerSearchData *data, GError **error)
 #else
        retry:
 #endif
+       gda_ldap_execution_slowdown (data->cnc);
        res = ldap_search_ext_s (data->cdata->handle, data->model->priv->current_exec->base_dn, lscope,
                                 data->model->priv->filter,
                                 (char**) data->model->priv->attributes->data, 0,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]