mirror of
https://github.com/samba-team/samba.git
synced 2025-07-23 20:59:10 +03:00
dsdb-schema: do not reload more often than schema_reload_interval
Samba 4 use to try to reload the schema every time dsdb_get_schema was called (which could be 20+ time per ldb request). Now we only reload at most every xx seconds (xx being the value of dsdb:"schema_reload_interval" or 120). The timestamp of the last reloaded schema is kept in the dsdb_schema object. There is also a timestamp in the ldb_context, that is used by the LDAP server to know if it has to reload the schema after handling the request. This is used to allow that the schema will be immediately reload after a schemaUpdateNow request has been issued, the reload can't occur in the handling of the LDAP request itself because we have a transaction autostarted.
This commit is contained in:
@ -1162,6 +1162,9 @@ NTSTATUS ldapsrv_do_call(struct ldapsrv_call *call)
|
||||
{
|
||||
unsigned int i;
|
||||
struct ldap_message *msg = call->request;
|
||||
struct ldb_context *samdb = call->conn->ldb;
|
||||
NTSTATUS status;
|
||||
time_t *lastts;
|
||||
/* Check for undecoded critical extensions */
|
||||
for (i=0; msg->controls && msg->controls[i]; i++) {
|
||||
if (!msg->controls_decoded[i] &&
|
||||
@ -1180,9 +1183,11 @@ NTSTATUS ldapsrv_do_call(struct ldapsrv_call *call)
|
||||
case LDAP_TAG_SearchRequest:
|
||||
return ldapsrv_SearchRequest(call);
|
||||
case LDAP_TAG_ModifyRequest:
|
||||
return ldapsrv_ModifyRequest(call);
|
||||
status = ldapsrv_ModifyRequest(call);
|
||||
break;
|
||||
case LDAP_TAG_AddRequest:
|
||||
return ldapsrv_AddRequest(call);
|
||||
status = ldapsrv_AddRequest(call);
|
||||
break;
|
||||
case LDAP_TAG_DelRequest:
|
||||
return ldapsrv_DelRequest(call);
|
||||
case LDAP_TAG_ModifyDNRequest:
|
||||
@ -1196,4 +1201,20 @@ NTSTATUS ldapsrv_do_call(struct ldapsrv_call *call)
|
||||
default:
|
||||
return ldapsrv_unwilling(call, LDAP_PROTOCOL_ERROR);
|
||||
}
|
||||
|
||||
if (NT_STATUS_IS_OK(status)) {
|
||||
lastts = (time_t *)ldb_get_opaque(samdb, DSDB_OPAQUE_LAST_SCHEMA_UPDATE_MSG_OPAQUE_NAME);
|
||||
if (lastts && !*lastts) {
|
||||
DEBUG(10, ("Schema update now was requested, fullfilling the request ts = %d\n", lastts));
|
||||
/*
|
||||
* Just requesting the schema will do the trick
|
||||
* as the delay for reload is experied, we will have a reload
|
||||
* from the schema as expected as we are not yet in a transaction!
|
||||
*/
|
||||
dsdb_get_schema(samdb, NULL);
|
||||
*lastts = time(NULL);
|
||||
ldb_set_opaque(samdb, DSDB_OPAQUE_LAST_SCHEMA_UPDATE_MSG_OPAQUE_NAME, lastts);
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
Reference in New Issue
Block a user