HACK: Do not refresh the schema using the wrong event context
authorAndrew Bartlett <abartlet@samba.org>
Wed, 14 May 2014 08:12:03 +0000 (20:12 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Sun, 18 May 2014 23:00:14 +0000 (11:00 +1200)
What we really should do is have the refresh function and module be on a seperate object to the schema, only referring to the data and not excuting on the original ldb and event loop.

Andrew Bartlett

Change-Id: I9e4c12639856bd9ac57f5feb0be8d47377443c1f
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
source4/dsdb/samdb/ldb_modules/schema_load.c
source4/dsdb/schema/schema.h
source4/dsdb/schema/schema_set.c

index 25a780150a88b2e87ac1b81116717da847a8da24..66da7f918e53d6beeba06d1fc16f1fbb45f33aab 100644 (file)
@@ -155,7 +155,8 @@ static int schema_metadata_get_uint64(struct ldb_module *module,
        return LDB_SUCCESS;
 }
 
-static struct dsdb_schema *dsdb_schema_refresh(struct ldb_module *module, struct dsdb_schema *schema, bool is_global_schema)
+static struct dsdb_schema *dsdb_schema_refresh(struct ldb_module *module, struct tevent_context *ev, 
+                                              struct dsdb_schema *schema, bool is_global_schema)
 {
        uint64_t current_usn, value;
        int ret;
@@ -174,6 +175,11 @@ static struct dsdb_schema *dsdb_schema_refresh(struct ldb_module *module, struct
                return schema;
        }
 
+       if (ev != ldb_get_event_context(ldb)) {
+               /* We do NOT want to execute an operation on another event context */
+               return schema;
+       }
+
        lastts = schema->last_refresh;
        ts = time(NULL);
        if (lastts > (ts - schema->refresh_interval)) {
index 538b8581234c150ab405fda33513f2706d550f7b..3b49a1a4a3e49349abba21aa0d9ccef646d76782 100644 (file)
@@ -251,7 +251,9 @@ struct dsdb_schema {
 
        /* Was this schema loaded from ldb (if so, then we will reload it when we detect a change in ldb) */
        struct ldb_module *loaded_from_module;
-       struct dsdb_schema *(*refresh_fn)(struct ldb_module *module, struct dsdb_schema *schema, bool is_global_schema);
+       struct dsdb_schema *(*refresh_fn)(struct ldb_module *module, 
+                                         struct tevent_context *ev, 
+                                         struct dsdb_schema *schema, bool is_global_schema);
        bool refresh_in_progress;
        time_t ts_last_change;
        time_t last_refresh;
index ce8facbef3c9e62f0ad027cf9d435cff44b30098..a49bb81e104769c73182460db1d7e6f78c29963a 100644 (file)
@@ -601,6 +601,7 @@ struct dsdb_schema *dsdb_get_schema(struct ldb_context *ldb, TALLOC_CTX *referen
                schema_in->refresh_in_progress = true;
                /* This may change schema, if it needs to reload it from disk */
                schema_out = schema_in->refresh_fn(schema_in->loaded_from_module,
+                                                  ldb_get_event_context(ldb),
                                                   schema_in,
                                                   use_global_schema);
                schema_in->refresh_in_progress = false;