diff --git a/branches/ucs-3.2/ucs-3.2-1/management/univention-directory-listener/src/cache_entry.c b/branches/ucs-3.2/ucs-3.2-1/management/univention-directory-listener/src/cache_entry.c index 3eb9ccc..b4685a0 100644 --- a/branches/ucs-3.2/ucs-3.2-1/management/univention-directory-listener/src/cache_entry.c +++ b/branches/ucs-3.2/ucs-3.2-1/management/univention-directory-listener/src/cache_entry.c @@ -377,136 +377,3 @@ char** cache_entry_changed_attributes(CacheEntry *new, CacheEntry *old) return changes; } - -int copy_cache_entry(CacheEntry *cache_entry, CacheEntry *backup_cache_entry) { - CacheEntryAttribute **cur1, **cur2; - int i=0; - int rv=0; - memset(backup_cache_entry, 0, sizeof(CacheEntry)); - for (cur1 = cache_entry->attributes; cur1 != NULL && *cur1 != NULL; cur1++) { - if ((backup_cache_entry->attributes = realloc(backup_cache_entry->attributes, (backup_cache_entry->attribute_count+2)*sizeof(CacheEntryAttribute*))) == NULL) { - univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "copy_cache_entry: realloc of attributes array failed"); - rv = 1; - goto result; - } - if ((backup_cache_entry->attributes[backup_cache_entry->attribute_count] = malloc(sizeof(CacheEntryAttribute))) == NULL) { - univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "copy_cache_entry: malloc for CacheEntryAttribute failed"); - rv = 1; - goto result; - } - cur2 = &backup_cache_entry->attributes[backup_cache_entry->attribute_count]; - (*cur2)->name=strdup((*cur1)->name); - (*cur2)->values=NULL; - (*cur2)->length=NULL; - (*cur2)->value_count=0; - backup_cache_entry->attributes[backup_cache_entry->attribute_count+1]=NULL; - - for (i = 0; i < (*cur1)->value_count; i++) { - if (((*cur2)->values = realloc((*cur2)->values, ((*cur2)->value_count+2)*sizeof(char*))) == NULL) { - univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "copy_cache_entry: realloc of values array failed"); - rv = 1; - goto result; - } - if (((*cur2)->length = realloc((*cur2)->length, ((*cur2)->value_count+2)*sizeof(int))) == NULL) { - univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "copy_cache_entry: realloc of length array failed"); - rv = 1; - goto result; - } - if ((*cur1)->length[i] == strlen((*cur1)->values[i]) + 1) { - if (((*cur2)->values[(*cur2)->value_count]=strdup((*cur1)->values[i])) == NULL) { - univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "copy_cache_entry: strdup of value failed"); - rv = 1; - goto result; - } - (*cur2)->length[(*cur2)->value_count]=strlen((*cur2)->values[(*cur2)->value_count])+1; - } else { - if (((*cur2)->values[(*cur2)->value_count]=malloc(((*cur1)->length[i])*sizeof(char))) == NULL) { - univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "copy_cache_entry: malloc for value failed"); - rv = 1; - goto result; - } - memcpy((*cur2)->values[(*cur2)->value_count],(*cur1)->values[i],(*cur1)->length[i]); - (*cur2)->length[(*cur2)->value_count]=(*cur1)->length[i]; - } - (*cur2)->values[(*cur2)->value_count+1]=NULL; - (*cur2)->value_count++; - } - backup_cache_entry->attribute_count++; - } - char **module_ptr; - for (module_ptr=cache_entry->modules; module_ptr != NULL && *module_ptr != NULL; module_ptr++) { - backup_cache_entry->modules = realloc(backup_cache_entry->modules, (backup_cache_entry->module_count+2)*sizeof(char*)); - backup_cache_entry->modules[backup_cache_entry->module_count] = strdup(*module_ptr); - backup_cache_entry->modules[backup_cache_entry->module_count+1] = NULL; - backup_cache_entry->module_count++; - } -result: - return rv; -} - -void compare_cache_entries(CacheEntry *lentry, CacheEntry *rentry) -{ - char **changes; - char **cur; - int i=0; - - changes = cache_entry_changed_attributes(lentry, rentry); - - for (cur = changes; cur != NULL && *cur != NULL; cur++) { - univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "ALERT: %s differs\n", *cur); - - for (i=0; lentry->attributes != NULL && lentry->attributes[i] != NULL; i++) { - if (STREQ(lentry->attributes[i]->name, *cur)) - break; - } - if (lentry->attributes == NULL || lentry->attributes[i] == NULL) { - univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "ALERT: lentry = []\n"); - } else { - int j; - univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "ALERT: lentry = ["); - for (j=0; lentry->attributes[i]->values && - lentry->attributes[i]->values[j] != NULL; - j++) { - univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, j == 0 ? "%s" : ", %s", lentry->attributes[i]->values[j]); - } - univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "]\n"); - } - - for (i=0; rentry->attributes != NULL && rentry->attributes[i] != NULL; i++) { - if (STREQ(rentry->attributes[i]->name, *cur)) - break; - } - if (rentry->attributes == NULL || rentry->attributes[i] == NULL) { - univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "ALERT: rentry = []\n"); - } else { - int j; - univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "ALERT: rentry = ["); - for (j=0; rentry->attributes[i]->values && - rentry->attributes[i]->values[j] != NULL; - j++) { - univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, j == 0 ? "%s" : ", %s", rentry->attributes[i]->values[j]); - } - univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "]\n"); - } - } - free(changes); - - char **cur1, **cur2; - - for (cur1=lentry->modules; cur1 != NULL && *cur1 != NULL; cur1++) { - for (cur2=rentry->modules; cur2 != NULL && *cur2 != NULL; cur2++) - if (STREQ(*cur1, *cur2)) - break; - if (cur2 != NULL && *cur2 != NULL) - continue; - univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "ALERT: module %s on lentry missing on rentry\n", *cur1); - } - for (cur2=rentry->modules; cur2 != NULL && *cur2 != NULL; cur2++) { - for (cur1=lentry->modules; cur1 != NULL && *cur1 != NULL; cur1++) - if (STREQ(*cur1, *cur2)) - break; - if (cur1 != NULL && *cur1 != NULL) - continue; - univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "ALERT: module %s on rentry missing on lentry\n", *cur2); - } -} diff --git a/branches/ucs-3.2/ucs-3.2-1/management/univention-directory-listener/src/cache_entry.h b/branches/ucs-3.2/ucs-3.2-1/management/univention-directory-listener/src/cache_entry.h index 8b9b383..12a6faa 100644 --- a/branches/ucs-3.2/ucs-3.2-1/management/univention-directory-listener/src/cache_entry.h +++ b/branches/ucs-3.2/ucs-3.2-1/management/univention-directory-listener/src/cache_entry.h @@ -68,10 +68,4 @@ int cache_entry_module_present (CacheEntry *entry, char** cache_entry_changed_attributes (CacheEntry *new, CacheEntry *old); -int copy_cache_entry (CacheEntry *cache_entry, - CacheEntry *backup_cache_entry); - -void compare_cache_entries (CacheEntry *lentry, - CacheEntry *rentry); - #endif /* _CACHE_ENTRY_H_ */ diff --git a/branches/ucs-3.2/ucs-3.2-1/management/univention-directory-listener/src/change.c b/branches/ucs-3.2/ucs-3.2-1/management/univention-directory-listener/src/change.c index 72f1fac..0870f96 100644 --- a/branches/ucs-3.2/ucs-3.2-1/management/univention-directory-listener/src/change.c +++ b/branches/ucs-3.2/ucs-3.2-1/management/univention-directory-listener/src/change.c @@ -118,7 +118,7 @@ int change_init_module(univention_ldap_parameters_t *lp, Handler *handler) } else if (rv == 0) { signals_block(); cache_update_entry(0, "cn=subschema", &cache_entry); - handler_update("cn=Subschema", &cache_entry, &old_cache_entry, handler, 'n', NULL); + handler_update("cn=Subschema", &cache_entry, &old_cache_entry, handler, 'n'); signals_unblock(); cache_free_entry(NULL, &cache_entry); } @@ -186,15 +186,8 @@ int change_init_module(univention_ldap_parameters_t *lp, Handler *handler) } signals_block(); - - /* First copy the entry for the local cache to be sure the entry in the cache is untouched. Bug #21914 */ - CacheEntry updated_cache_entry; - copy_cache_entry(&cache_entry, &updated_cache_entry); - handler_update(dns[i].dn, &cache_entry, &old_cache_entry, handler, 'n', &updated_cache_entry); - //compare_cache_entries(&cache_entry, &updated_cache_entry); - cache_update_entry_lower(0, dns[i].dn, &updated_cache_entry); - cache_free_entry(NULL, &updated_cache_entry); - + handler_update(dns[i].dn, &cache_entry, &old_cache_entry, handler, 'n'); + cache_update_entry_lower(0, dns[i].dn, &cache_entry); signals_unblock(); cache_free_entry(NULL, &cache_entry); } @@ -238,12 +231,11 @@ static int change_update_entry(univention_ldap_parameters_t *lp, NotifierID id, LDAPMessage *ldap_entry, char command) { char *dn=NULL; - CacheEntry cache_entry, old_cache_entry, updated_cache_entry; + CacheEntry cache_entry, old_cache_entry; int rv = 0; memset(&cache_entry, 0, sizeof(CacheEntry)); memset(&old_cache_entry, 0, sizeof(CacheEntry)); - memset(&updated_cache_entry, 0, sizeof(CacheEntry)); if ((rv=cache_new_entry_from_ldap(&dn, &cache_entry, lp->ld, ldap_entry)) != 0) { univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_WARN, "error while converting LDAP entry to cache entry"); @@ -254,11 +246,8 @@ int change_update_entry(univention_ldap_parameters_t *lp, NotifierID id, LDAPMes rv = LDAP_OTHER; } else { signals_block(); - /* First copy the entry for the local cache to be sure the entry in the cache is untouched. Bug #21914 */ - copy_cache_entry(&cache_entry, &updated_cache_entry); - handlers_update(dn, &cache_entry, &old_cache_entry, command, &updated_cache_entry); - //compare_cache_entries(&cache_entry, &updated_cache_entry); - if ((rv=cache_update_entry_lower(id, dn, &updated_cache_entry)) != 0) { + handlers_update(dn, &cache_entry, &old_cache_entry, command); + if ((rv=cache_update_entry_lower(id, dn, &cache_entry)) != 0) { univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_WARN, "error while writing to database"); } rv=0; @@ -268,7 +257,6 @@ int change_update_entry(univention_ldap_parameters_t *lp, NotifierID id, LDAPMes result: cache_free_entry(&dn, &cache_entry); cache_free_entry(NULL, &old_cache_entry); - cache_free_entry(NULL, &updated_cache_entry); return rv; } diff --git a/branches/ucs-3.2/ucs-3.2-1/management/univention-directory-listener/src/handlers.c b/branches/ucs-3.2/ucs-3.2-1/management/univention-directory-listener/src/handlers.c index 628a4e4..807169d 100644 --- a/branches/ucs-3.2/ucs-3.2-1/management/univention-directory-listener/src/handlers.c +++ b/branches/ucs-3.2/ucs-3.2-1/management/univention-directory-listener/src/handlers.c @@ -759,7 +759,7 @@ int attribute_has_changed(char** changes, char* attribute) /* a little more low-level interface than handler_update */ -static int handler__update(Handler *handler, char *dn, CacheEntry *new, CacheEntry *old, char command, char **changes, CacheEntry *scratch) +static int handler__update(Handler *handler, char *dn, CacheEntry *new, CacheEntry *old, char command, char **changes) { int matched; int rv = 0; @@ -792,9 +792,6 @@ static int handler__update(Handler *handler, char *dn, CacheEntry *new, CacheEnt if (uptodate) { univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_INFO, "handler: %s (up-to-date)", handler->name); cache_entry_module_add(new, handler->name); - if ( scratch != NULL ) { - cache_entry_module_add(scratch, handler->name); - } return 0; } } @@ -809,9 +806,6 @@ static int handler__update(Handler *handler, char *dn, CacheEntry *new, CacheEnt /* run handler */ if (handler_exec(handler, dn, new, old, command) == 0) { cache_entry_module_add(new, handler->name); - if ( scratch != NULL ) { - cache_entry_module_add(scratch, handler->name); - } univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_INFO, "handler: %s (successful)", handler->name); } else { univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_WARN, "handler: %s (failed)", handler->name); @@ -823,7 +817,7 @@ static int handler__update(Handler *handler, char *dn, CacheEntry *new, CacheEnt /* run all handlers if object has changed */ -int handlers_update(char *dn, CacheEntry *new, CacheEntry *old, char command, CacheEntry *scratch) +int handlers_update(char *dn, CacheEntry *new, CacheEntry *old, char command) { Handler *handler; char** changes; @@ -835,12 +829,12 @@ int handlers_update(char *dn, CacheEntry *new, CacheEntry *old, char command, Ca for (handler=handlers; handler != NULL; handler=handler->next) { if (STREQ(handler->name, "replication")) { - handler__update(handler, dn, new, old, command, changes, scratch); + handler__update(handler, dn, new, old, command, changes); } } for (handler=handlers; handler != NULL; handler=handler->next) { if (STRNEQ(handler->name, "replication")) { - handler__update(handler, dn, new, old, command, changes, scratch); + handler__update(handler, dn, new, old, command, changes); } } free(changes); @@ -850,7 +844,7 @@ int handlers_update(char *dn, CacheEntry *new, CacheEntry *old, char command, Ca /* run given handler if object has changed */ -int handler_update(char *dn, CacheEntry *new, CacheEntry *old, Handler *handler, char command, CacheEntry *scratch) +int handler_update(char *dn, CacheEntry *new, CacheEntry *old, Handler *handler, char command) { char** changes; int rv = 0; @@ -859,7 +853,7 @@ int handler_update(char *dn, CacheEntry *new, CacheEntry *old, Handler *handler, changes = cache_entry_changed_attributes(new, old); - rv = handler__update(handler, dn, new, old, command, changes, scratch); + rv = handler__update(handler, dn, new, old, command, changes); free(changes); diff --git a/branches/ucs-3.2/ucs-3.2-1/management/univention-directory-listener/src/handlers.h b/branches/ucs-3.2/ucs-3.2-1/management/univention-directory-listener/src/handlers.h index f910605..a597cbb 100644 --- a/branches/ucs-3.2/ucs-3.2-1/management/univention-directory-listener/src/handlers.h +++ b/branches/ucs-3.2/ucs-3.2-1/management/univention-directory-listener/src/handlers.h @@ -87,14 +87,12 @@ int handlers_dump (void); int handlers_update (char *dn, CacheEntry *new, CacheEntry *old, - char command, - CacheEntry *scratch); + char command); int handler_update (char *dn, CacheEntry *new, CacheEntry *old, Handler *handler, - char command, - CacheEntry *scratch); + char command); int handlers_delete (char *dn, CacheEntry *old, char command);