mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-21 07:09:34 -05:00
slightly reduce malloc overhead; minor cleanup
This commit is contained in:
parent
c66a92f935
commit
c3fd851a59
6 changed files with 17 additions and 25 deletions
|
|
@ -309,7 +309,7 @@ meta_back_dobind( struct metaconn *lc, Operation *op, ldap_back_send_t sendok )
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( i = 0, lsc = lc->mc_conns; !META_LAST( lsc ); ++i, ++lsc ) {
|
for ( i = 0, lsc = &lc->mc_conns[ 0 ]; !META_LAST( lsc ); ++i, ++lsc ) {
|
||||||
int rc;
|
int rc;
|
||||||
struct berval cred = BER_BVC("");
|
struct berval cred = BER_BVC("");
|
||||||
int msgid;
|
int msgid;
|
||||||
|
|
@ -432,7 +432,7 @@ meta_back_is_valid( struct metaconn *lc, int candidate )
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( i = 0, lsc = lc->mc_conns; !META_LAST( lsc ) && i < candidate;
|
for ( i = 0, lsc = &lc->mc_conns[ 0 ]; !META_LAST( lsc ) && i < candidate;
|
||||||
++i, ++lsc );
|
++i, ++lsc );
|
||||||
|
|
||||||
if ( !META_LAST( lsc ) ) {
|
if ( !META_LAST( lsc ) ) {
|
||||||
|
|
@ -512,7 +512,7 @@ meta_back_op_result(
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
for ( i = 0, lsc = lc->mc_conns; !META_LAST( lsc ); ++i, ++lsc ) {
|
for ( i = 0, lsc = &lc->mc_conns[ 0 ]; !META_LAST( lsc ); ++i, ++lsc ) {
|
||||||
char *msg = NULL;
|
char *msg = NULL;
|
||||||
char *match = NULL;
|
char *match = NULL;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ meta_back_compare( Operation *op, SlapReply *rs )
|
||||||
dc.rs = rs;
|
dc.rs = rs;
|
||||||
dc.ctx = "compareDN";
|
dc.ctx = "compareDN";
|
||||||
|
|
||||||
for ( i = 0, lsc = lc->mc_conns; !META_LAST( lsc ); ++i, ++lsc ) {
|
for ( i = 0, lsc = &lc->mc_conns[ 0 ]; !META_LAST( lsc ); ++i, ++lsc ) {
|
||||||
struct berval mdn = BER_BVNULL;
|
struct berval mdn = BER_BVNULL;
|
||||||
struct berval mapped_attr = op->orc_ava->aa_desc->ad_cname;
|
struct berval mapped_attr = op->orc_ava->aa_desc->ad_cname;
|
||||||
struct berval mapped_value = op->orc_ava->aa_value;
|
struct berval mapped_value = op->orc_ava->aa_value;
|
||||||
|
|
@ -171,7 +171,7 @@ meta_back_compare( Operation *op, SlapReply *rs )
|
||||||
/*
|
/*
|
||||||
* FIXME: should we check for abandon?
|
* FIXME: should we check for abandon?
|
||||||
*/
|
*/
|
||||||
for ( i = 0, lsc = lc->mc_conns; !META_LAST( lsc ); lsc++, i++ ) {
|
for ( i = 0, lsc = &lc->mc_conns[ 0 ]; !META_LAST( lsc ); lsc++, i++ ) {
|
||||||
int lrc;
|
int lrc;
|
||||||
LDAPMessage *res = NULL;
|
LDAPMessage *res = NULL;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -128,19 +128,14 @@ metaconn_alloc( int ntargets )
|
||||||
|
|
||||||
assert( ntargets > 0 );
|
assert( ntargets > 0 );
|
||||||
|
|
||||||
lc = ch_calloc( sizeof( struct metaconn ), 1 );
|
/* malloc once only; leave an extra one for one-past-end */
|
||||||
|
lc = ch_malloc( sizeof( struct metaconn )
|
||||||
|
+ sizeof( struct metasingleconn ) * ( ntargets + 1 ) );
|
||||||
if ( lc == NULL ) {
|
if ( lc == NULL ) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
lc->mc_conns = (struct metasingleconn *)&lc[ 1 ];
|
||||||
* make it a null-terminated array ...
|
|
||||||
*/
|
|
||||||
lc->mc_conns = ch_calloc( sizeof( struct metasingleconn ), ntargets + 1 );
|
|
||||||
if ( lc->mc_conns == NULL ) {
|
|
||||||
free( lc );
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* FIXME: needed by META_LAST() */
|
/* FIXME: needed by META_LAST() */
|
||||||
lc->mc_conns[ ntargets ].msc_candidate = META_LAST_CONN;
|
lc->mc_conns[ ntargets ].msc_candidate = META_LAST_CONN;
|
||||||
|
|
@ -171,10 +166,6 @@ metaconn_free(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( lc->mc_conns ) {
|
|
||||||
ch_free( lc->mc_conns );
|
|
||||||
}
|
|
||||||
|
|
||||||
free( lc );
|
free( lc );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,9 @@ conn_free(
|
||||||
struct metaconn *lc = v_lc;
|
struct metaconn *lc = v_lc;
|
||||||
struct metasingleconn *lsc;
|
struct metasingleconn *lsc;
|
||||||
|
|
||||||
for ( lsc = lc->mc_conns; !META_LAST( lsc ); lsc++ ) {
|
assert( lc->mc_conns != NULL );
|
||||||
|
|
||||||
|
for ( lsc = &lc->mc_conns[ 0 ]; !META_LAST( lsc ); lsc++ ) {
|
||||||
if ( lsc->msc_ld != NULL ) {
|
if ( lsc->msc_ld != NULL ) {
|
||||||
ldap_unbind_ext_s( lsc->msc_ld, NULL, NULL );
|
ldap_unbind_ext_s( lsc->msc_ld, NULL, NULL );
|
||||||
}
|
}
|
||||||
|
|
@ -117,7 +119,7 @@ conn_free(
|
||||||
ber_memfree( lsc->msc_cred.bv_val );
|
ber_memfree( lsc->msc_cred.bv_val );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free( lc->mc_conns );
|
|
||||||
free( lc );
|
free( lc );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ meta_back_search( Operation *op, SlapReply *rs )
|
||||||
/*
|
/*
|
||||||
* Inits searches
|
* Inits searches
|
||||||
*/
|
*/
|
||||||
for ( i = 0, lsc = lc->mc_conns; !META_LAST( lsc ); ++i, ++lsc ) {
|
for ( i = 0, lsc = &lc->mc_conns[ 0 ]; !META_LAST( lsc ); ++i, ++lsc ) {
|
||||||
struct berval realbase = op->o_req_dn;
|
struct berval realbase = op->o_req_dn;
|
||||||
int realscope = op->ors_scope;
|
int realscope = op->ors_scope;
|
||||||
ber_len_t suffixlen = 0;
|
ber_len_t suffixlen = 0;
|
||||||
|
|
@ -300,7 +300,7 @@ new_candidate:;
|
||||||
/* check for abandon */
|
/* check for abandon */
|
||||||
ab = op->o_abandon;
|
ab = op->o_abandon;
|
||||||
|
|
||||||
for ( i = 0, lsc = lc->mc_conns; !META_LAST( lsc ); lsc++, i++ ) {
|
for ( i = 0, lsc = &lc->mc_conns[ 0 ]; !META_LAST( lsc ); lsc++, i++ ) {
|
||||||
if ( msgid[ i ] == -1 ) {
|
if ( msgid[ i ] == -1 ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#include <ac/socket.h>
|
#include <ac/socket.h>
|
||||||
#include <ac/string.h>
|
#include <ac/string.h>
|
||||||
|
#include <ac/errno.h>
|
||||||
|
|
||||||
#include "slap.h"
|
#include "slap.h"
|
||||||
#include "../back-ldap/back-ldap.h"
|
#include "../back-ldap/back-ldap.h"
|
||||||
|
|
@ -70,8 +71,6 @@ meta_back_conn_destroy(
|
||||||
rewrite_session_delete( li->mi_targets[ i ]->mt_rwmap.rwm_rw, conn );
|
rewrite_session_delete( li->mi_targets[ i ]->mt_rwmap.rwm_rw, conn );
|
||||||
meta_clear_one_candidate( &lc->mc_conns[ i ] );
|
meta_clear_one_candidate( &lc->mc_conns[ i ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
free( lc->mc_conns );
|
|
||||||
free( lc );
|
free( lc );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue