Univention Bugzilla – Attachment 4123 Details for
Bug 25958
Listener Performance in großen Umgebungen
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch zum effizienteren realloc bei vielen Attribut-Werten.
2.diff (text/plain), 4.64 KB, created by
Arvid Requate
on 2012-01-30 15:33:48 CET
(
hide
)
Description:
Patch zum effizienteren realloc bei vielen Attribut-Werten.
Filename:
MIME Type:
Creator:
Arvid Requate
Created:
2012-01-30 15:33:48 CET
Size:
4.64 KB
patch
obsolete
>--- univention-directory-listener/src/cache_entry.c.orig 2012-01-30 15:15:41.000000000 +0100 >+++ univention-directory-listener/src/cache_entry.c 2012-01-30 15:21:19.000000000 +0100 >@@ -250,6 +250,18 @@ int cache_new_entry_from_ldap(char **dn, > rv = 1; > goto result; > } >+ int vals = ldap_count_values_len(val); >+ if ((cache_entry->attributes[cache_entry->attribute_count]->values = realloc(cache_entry->attributes[cache_entry->attribute_count]->values, (vals+1)*sizeof(char*))) == NULL) { >+ univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "cache_new_entry_from_ldap: realloc of values array failed"); >+ rv = 1; >+ goto result; >+ } >+ if ((cache_entry->attributes[cache_entry->attribute_count]->length = realloc(cache_entry->attributes[cache_entry->attribute_count]->length, (vals+1)*sizeof(int))) == NULL) { >+ univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "cache_new_entry_from_ldap: realloc of length array failed"); >+ rv = 1; >+ goto result; >+ } >+ > for (v = val; *v != NULL; v++) { > if ( (*v)->bv_val == NULL ) { > // check here, strlen behavior might be undefined in this case >@@ -291,34 +303,14 @@ int cache_new_entry_from_ldap(char **dn, > continue; > } > } >- if ((cache_entry->attributes[cache_entry->attribute_count]->values = realloc(cache_entry->attributes[cache_entry->attribute_count]->values, (cache_entry->attributes[cache_entry->attribute_count]->value_count+2)*sizeof(char*))) == NULL) { >- univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "cache_new_entry_from_ldap: realloc of values array failed"); >+ if ((cache_entry->attributes[cache_entry->attribute_count]->values[cache_entry->attributes[cache_entry->attribute_count]->value_count]=malloc(((*v)->bv_len+1)*sizeof(char))) == NULL) { >+ univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "cache_new_entry_from_ldap: malloc for value failed"); > rv = 1; > goto result; > } >- if ((cache_entry->attributes[cache_entry->attribute_count]->length = realloc(cache_entry->attributes[cache_entry->attribute_count]->length, (cache_entry->attributes[cache_entry->attribute_count]->value_count+2)*sizeof(int))) == NULL) { >- univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "cache_new_entry_from_ldap: realloc of length array failed"); >- rv = 1; >- goto result; >- } >- if ((*v)->bv_len == strlen((*v)->bv_val)) { >- if ((cache_entry->attributes[cache_entry->attribute_count]->values[cache_entry->attributes[cache_entry->attribute_count]->value_count]=strdup((*v)->bv_val)) == NULL) { >- univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "cache_new_entry_from_ldap: strdup of value failed"); >- rv = 1; >- goto result; >- } >- cache_entry->attributes[cache_entry->attribute_count]->length[cache_entry->attributes[cache_entry->attribute_count]->value_count]=strlen(cache_entry->attributes[cache_entry->attribute_count]->values[cache_entry->attributes[cache_entry->attribute_count]->value_count])+1; >- } else { // in this case something is strange about the string in bv_val, maybe contains a '\0' >- // the legacy approach is to copy bv_len bytes, let's stick with this and just terminate to be safe >- if ((cache_entry->attributes[cache_entry->attribute_count]->values[cache_entry->attributes[cache_entry->attribute_count]->value_count]=malloc(((*v)->bv_len+1)*sizeof(char))) == NULL) { >- univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "cache_new_entry_from_ldap: malloc for value failed"); >- rv = 1; >- goto result; >- } >- memcpy(cache_entry->attributes[cache_entry->attribute_count]->values[cache_entry->attributes[cache_entry->attribute_count]->value_count],(*v)->bv_val,(*v)->bv_len); >- cache_entry->attributes[cache_entry->attribute_count]->values[cache_entry->attributes[cache_entry->attribute_count]->value_count][(*v)->bv_len]='\0'; // terminate the string to be safe >- cache_entry->attributes[cache_entry->attribute_count]->length[cache_entry->attributes[cache_entry->attribute_count]->value_count]=(*v)->bv_len+1; >- } >+ memcpy(cache_entry->attributes[cache_entry->attribute_count]->values[cache_entry->attributes[cache_entry->attribute_count]->value_count],(*v)->bv_val,(*v)->bv_len); >+ cache_entry->attributes[cache_entry->attribute_count]->values[cache_entry->attributes[cache_entry->attribute_count]->value_count][(*v)->bv_len]='\0'; // terminate the string to be safe >+ cache_entry->attributes[cache_entry->attribute_count]->length[cache_entry->attributes[cache_entry->attribute_count]->value_count]=(*v)->bv_len+1; > cache_entry->attributes[cache_entry->attribute_count]->values[cache_entry->attributes[cache_entry->attribute_count]->value_count+1]=NULL; > cache_entry->attributes[cache_entry->attribute_count]->value_count++; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 25958
:
4122
| 4123 |
4124
|
4125
|
4126